On this page:
redis-pool?
make-redis-pool
redis-pool-shutdown!
call-with-redis-client

2 Connection Pooling

procedure

(redis-pool? v)  boolean?

  v : any/c
Returns #t if v is a pool of Redis connections.

procedure

(make-redis-pool [#:client-name client-name    
  #:host host    
  #:port port    
  #:timeout timeout    
  #:db db    
  #:password password    
  #:pool-size pool-size    
  #:idle-ttl idle-ttl])  redis-pool?
  client-name : non-empty-string? = "racket-redis"
  host : non-empty-string? = "127.0.0.1"
  port : (integer-in 0 65536) = 6379
  timeout : exact-nonnegative-integer? = 5000
  db : (integer-in 0 15) = 0
  password : (or/c false/c non-empty-string?) = #f
  pool-size : exact-positive-integer? = 4
  idle-ttl : exact-nonnegative-integer? = 3600
Creates a lazy pool of Redis connections that will contain at most pool-size connections.

Connections that have been idle for more than idle-ttl seconds are lazily reconnected.

All other parameters are passed directly to make-redis whenever a new connection is initiated.

procedure

(redis-pool-shutdown! pool)  void?

  pool : redis-pool?
Shuts down pool and closes any of its open connections. Once shut down, a pool can no longer be used.

procedure

(call-with-redis-client pool    
  proc    
  [#:timeout timeout])  any
  pool : redis-pool?
  proc : (-> redis? any)
  timeout : (or/c false/c exact-nonnegative-integer?) = #f
Grabs a connection from the pool and calls proc with it, ensuring that the connection is returned to the pool upon completion.

Holding on to a connection past the execution of proc is a bad idea so don’t do it.

This function blocks until either a connection becomes available or the timeout (milliseconds) is reached. If timeout is #f, then the function will block indefinitely. Upon timeout an exn:fail:redis:pool:timeout exception is raised.