sorentwo / readthis

:newspaper: Pooled active support compliant caching with redis
MIT License
504 stars 40 forks source link

How to close redis connection? #62

Closed nicozhang closed 6 years ago

nicozhang commented 6 years ago

I use Readthis::Cache.new to get a client, but i can not find a way to close this redis connection. So I meet a very serious problem of redis, max number of clients reached.

sorentwo commented 6 years ago

All of the redis connections are stored in a connection pool. You can technically close connections by shutting down the pool, but that will leave the cache in a bad state.

The default pool size is 5, so you'll get at most 5 connections if you have enough parallel traffic. If you have very low connection limits you can configure a smaller pool size using the pool_size option:

Readthis::Cache.new(pool_size: 2)