rack-cache icon indicating copy to clipboard operation
rack-cache copied to clipboard

BYO-Cache

Open grosser opened this issue 12 years ago • 5 comments

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.

grosser avatar Jun 18 '12 17:06 grosser

As backend you could use https://github.com/minad/moneta

minad avatar Dec 08 '12 23:12 minad

Yep, same []/[]= interface, would be nice if we could just plug anything in :)

grosser avatar Dec 09 '12 03:12 grosser

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.

minad avatar Dec 09 '12 17:12 minad

Thanks, redis->juno->rack it is then... still feels like a wtf solution to a dead-simple problem...

grosser avatar Dec 09 '12 17:12 grosser

@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 ?

grosser avatar Sep 09 '14 15:09 grosser