Set custom stores #38

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
5 participants
Contributor

tekwiz commented Sep 11, 2011

This allows the registration and resolution of custom stores.

Example from updated docs:

use Rack::Cache do |rack_cache|
  rack_cache.register_metastore, :my_metas,
    ::Cache::MetaStore::Heap.new
  rack_cache.register_entitystore, :my_entities,
    ::Cache::EntityStore::Heap.new
  rack_cache.use :metastore, :my_metas
  rack_cache.use :entitystore, :my_entities
end

or

Rack::Cache::Storage.instance.register_metastore :my_metas,
  Rack::Cache::MetaStore::Heap.new
Rack::Cache::Storage.instance.register_entitystore :my_entities,
  Rack::Cache::EntityStore::Heap.new

use Rack::Cache,
  :metastore => :my_metas,
  :entitystore => :my_entities

This is especially useful for redis-store when you use a distributed instance:

redis_servers = %w(redis://app1.domain.com redis://app2.domain.com)
use Rack::Cache do |rack_cache|
  rack_cache.register_metastore, :default,
    Rack::Cache::MetaStore::Redis.new(redis_servers)
  rack_cache.use :metastore, :my_metas

end

afeld commented Feb 2, 2012

bump!

Owner

rtomayko commented Feb 17, 2012

Really sorry for the lack of attention on this. I definitely like this patch in concept. It's something that should have been done a long time ago and cleans up a really ugly part of the codebase.

I do think we should stick with URIs as storage identifiers instead of adding names, though. It's a little more work for the store implementation but allows for common things like hostnames, namespaces, and params to be given a standard way.

I'd also like the built in stores to use the same interfaces for registering as custom stores.

I'm planning on spending a couple days in rack-cache this weekend maybe. I'd love to use this as a base for moving things in a slightly different direction. Does that sound okay?

cfis commented Oct 15, 2012

Hi Ryan,

Travis and I worked on this one - any chance of pushing it forward? Need a new patch?

Thanks - Charlie

Collaborator

grosser commented Oct 8, 2015

please reopen if still needed

grosser closed this Oct 8, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment