lack-session-store-redis-pool

May 25, 2024 ยท View on GitHub

This project is a fork of lack-session-store-redis that adds connection pooling using anypool.

Usage

Wrap app:

(funcall lack/middleware/session:*lack-middleware-session*
         *app*
         :store (lack/middleware/session/store/redis-pool:make-redis-store
                 :host "redis01.acme.example.com"
                 :max-open-count 10
                 :max-idle-count 3))

Lack Builder:

(lack/builder
  (:session :store (lack/middleware/session/store/redis-pool:make-redis-store
                     :host "redis01.acme.example.com"
                     :max-open-count 10
                     :max-idle-count 3))
  *app*)

Store options

  • HOST: optional; the hostname of the Redis server to connect to (default: "127.0.0.1")
  • PORT: optional; the port number of the Redis server to connect to (default: 6379)
  • AUTH: optional; the Redis authentication password (default: NIL)
  • NAMESPACE: optional; the key prefix under which to write all session data (default: "session")
  • EXPIRES: optional; TTL for session data, in seconds (default: NIL)
  • SERIALIZER: optional; function for serializing Lisp data to Redis (default uses cl-marshal)
  • DESERIALIZER: optional; function for deserializing data from Redis back to Lisp (default uses cl-marshal)
  • POOL: optional; provide an ANYPOOL:POOL instance directly and skip other pool-related options (default: NIL)
  • POOL-NAME: optional; the name of the ANYPOOL:POOL instance (default: "lack-session-store-redis")
  • MAX-OPEN-COUNT: optional; passed through to ANYPOOL:MAKE-POOL keyword arguments (default: 8)
  • MAX-IDLE-COUNT: optional; passed through to ANYPOOL:MAKE-POOL keyword arguments (default: 4)
  • TIMEOUT: optional; passed through to ANYPOOL:MAKE-POOL keyword arguments (default: 2000)
  • IDLE-TIMEOUT: optional; passed through to ANYPOOL:MAKE-POOL keyword arguments (default: 60000)
  • ON-TOO-MANY-OPEN-CONNECTIONS: optional; function called from HANDLER-BIND handler for ANYPOOL:TOO-MANY-OPEN-CONNECTION error before re-signalling as REDIS-POOL-TIMEOUT-ERROR; may be useful for publishing a metric or some other purpose

Installation

Not in Quicklisp, so clone the repository to "local-projects/".

Development

Run tests:

(asdf:test-system :foo.lisp.lack-session-store-redis-pool)

Dependencies

Tests

Author

  • Eitaro Fukamachi (author of Lack, lack-session-store-redis)
  • John Newton (adapter & maintainer)

Original source, by Eitaro Fukamachi: lack/request

Adaptations by John Newton:

  • extract to separate git repository
  • add connection pooling

License

MIT