Cache store lookup name<Symbol> : The name of a registered store Returns<Nil AbstractStore> : A thread-safe copy of the store
# File lib/merb-cache/cache.rb, line 42 def self.[](*names) if names.size == 1 Thread.current[:'merb-cache'] ||= {} (Thread.current[:'merb-cache'][names.first] ||= stores[names.first].clone) else AdhocStore[*names] end rescue TypeError raise(StoreNotFound, "Could not find the :#{names.first} store") end
Clones the cache stores for the current thread
# File lib/merb-cache/cache.rb, line 54 def self.clone_stores @stores.inject({}) {|h, (k, s)| h[k] = s.clone; h} end
Default store name is :default.
# File lib/merb-cache/cache.rb, line 79 def self.default_store_name :default end
Checks to see if a given store exists already.
# File lib/merb-cache/cache.rb, line 72 def self.exists?(name) return true if self[name] rescue StoreNotFound return false end
Registers the cache store name with a type & options name<Symbol> : An optional symbol to give the cache. :default is used if no name is given. klass<Class> : A store type. opts<Hash> : A hash to pass through to the store for configuration.
# File lib/merb-cache/cache.rb, line 62 def self.register(name, klass = nil, opts = {}) klass, opts = nil, klass if klass.is_a? Hash name, klass = default_store_name, name if klass.nil? raise StoreExists, "#{name} store already setup" if @stores.has_key?(name) @stores[name] = (AdhocStore === klass) ? klass : klass.new(opts) end
Generated with the Darkfish Rdoc Generator 2.