rack-cache
rack-cache copied to clipboard
BYO-Cache
I'd like to "bring my own cache".
- Why are there so many cache-implementation-reinventions ?
- Why do I have to build something rack-specific just to get some caching ?
- Why do I have to even bother with entity/metastore ? (it may be nice for advanced users, but lets start simple)
can we just focus on support a simple interface like []/[]=/clear moneta style or read/write/fetch/clear and be done with this ?
- removes a ton of code/bugs/indirection
- make it easier to use
- makes it easier to debug
I don't want to learn how rack-cache works internally, does it really have to be more complicated then:
use Rack::Cache, :cache => Rails.cache
use Rack::Cache, :cache => MyOwnCachenew
maybe at most:
use Rack::Cache, :enititystore => Rails.cache, :metastore => ActiveSupport::Cache::Memorystore.new
would also solve support for mongodb/redis/multi-server-memcache etc and surely a few issues.
As backend you could use https://github.com/minad/moneta
Yep, same []/[]= interface, would be nice if we could just plug anything in :)
Added support to moneta for now:
https://github.com/minad/moneta/blob/master/lib/rack/cache/moneta.rb
You get a lot of key/value stores for free: redis, memcached, tokyo, riak, cassandra, couch, mongo, ...
This entitystore/metastore thing and the uri lookup thing are very much overengineered. It would be much better to replace this with something simpler.
Thanks, redis->juno->rack it is then... still feels like a wtf solution to a dead-simple problem...
@rtomayko just set up a new app an ran into exactly the same issue :( Would you merge a PR that remove all this caching magic and just accepts a cache-store that responds to read/write (railsy) or ([]/[]=) monetay ?