lack-middleware-redis
May 25, 2024 ยท View on GitHub
Usage
Wrap app:
(funcall lack/middleware/redis:*lack-middleware-redis*
*app*
:pools '((:pool-id :cache
:host "redis01.example.com"
:max-open-count 10
:max-idle-count 4
:timeout 2000
:idle-timeout 40000)))
Lack Builder:
(lack:builder
(:redis :pools '((:pool-id :cache
:host "redis01.example.com"
:port 6379
:max-open-count 10
:max-idle-count 4)
(:pool-id :jobs
:host "redis02.example.com"
:max-open-count 12)))
*app*)
Once you have a pool configured, you can call macro WITH-REDIS from your application to checkout a connection from the specified pool:
(with-redis (:cache)
(red:set "foo" "bar"))
Pool options
POOL-ID: required; unique name of the pool, a keywordPOOL-NAME: optional; passed through to theANYPOOL:MAKE-POOLas theNAMEparameter, defaulting to "redis-[downcased-pool-id]" if not providedHOST: optional; the hostname of the Redis server (default: 127.0.0.1)PORT: optional the port number of the Redis server; (default: 6379)AUTH: optional; password to authenticate to the Redis serverMAX-OPEN-COUNT: optional; passed through toANYPOOL:MAKE-POOL(default: 10)MAX-IDLE-COUNT: optional; passed through toANYPOOL:MAKE-POOL(default 4)TIMEOUT: optional; passed through toANYPOOL:MAKE-POOL; milliseconds to wait checking out a connection once MAX-OPEN-COUNT is reached (default: 2000)IDLE-TIMEOUT: optional; passed through toANYPOOL:MAKE-POOL(default: 30000)ON-TOO-MANY-OPEN-CONNECTIONS: optional; function called fromHANDLER-BINDhandler forANYPOOL:TOO-MANY-OPEN-CONNECTIONerror before returning a 503 response; may be useful for publishing a metric or some other purpose
Development
Run tests:
(asdf:test-system :foo.lisp.lack-middleware-redis)
Installation
Not in Quicklisp, so clone the repository to "local-projects/".
Dependencies
Middleware
Tests
Author
- John Newton (jnewton@lisplizards.dev)
Copyright
Copyright (c) 2024 John Newton
License
Apache-2.0