sorentwo / readthis

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

Commands not supported by ActiveSupport::Cache::Store #34

Closed espen closed 8 years ago

espen commented 8 years ago

I want to expire a key and the expire command is not available in ActiveSupport::Cache::Store. In Dalli it's possible to use the Dalli client directly: https://github.com/petergoldstein/dalli/blob/master/lib/active_support/cache/dalli_store.rb#L77. Would something similar be possible with readthis? Or how about adding additional methods like expire which is what redis-activesupport (redis-store) has done https://github.com/redis-store/redis-activesupport/blob/master/lib/active_support/cache/redis_store.rb#L190

sorentwo commented 8 years ago

You can run any command you like through the pool:

Rails.cache.pool.with { |client| client.expire(key, seconds) }
sorentwo commented 8 years ago

@espen I've added a section to the README to outline how you can run arbitrary commands. Thanks for bringing this up.

espen commented 8 years ago

Awesome. Thanks for the quick answer.