Merb::Cache

Constants

VERSION

Attributes

stores[RW]

Public Class Methods

[](*names) click to toggle source

Cache store lookup name : The name of a registered store Returns : A thread-safe copy of the store

    # File lib/merb-cache/cache.rb, line 42
42:     def self.[](*names)
43:       if names.size == 1
44:         Thread.current[:'merb-cache'] ||= {}
45:         (Thread.current[:'merb-cache'][names.first] ||= stores[names.first].clone)
46:       else
47:         AdhocStore[*names]
48:       end
49:     rescue TypeError
50:       raise(StoreNotFound, "Could not find the :#{names.first} store")
51:     end
clone_stores() click to toggle source

Clones the cache stores for the current thread

    # File lib/merb-cache/cache.rb, line 54
54:     def self.clone_stores
55:       @stores.inject({}) {|h, (k, s)| h[k] = s.clone; h}
56:     end
default_store_name() click to toggle source

Default store name is :default.

    # File lib/merb-cache/cache.rb, line 79
79:     def self.default_store_name
80:       :default
81:     end
exists?(name) click to toggle source

Checks to see if a given store exists already.

    # File lib/merb-cache/cache.rb, line 72
72:     def self.exists?(name)
73:       return true if self[name]
74:     rescue StoreNotFound
75:       return false
76:     end
register(name, klass = nil, opts = {}) click to toggle source

Registers the cache store name with a type & options name : An optional symbol to give the cache. :default is used if no name is given. klass : A store type. opts : A hash to pass through to the store for configuration.

    # File lib/merb-cache/cache.rb, line 62
62:     def self.register(name, klass = nil, opts = {})
63:       klass, opts = nil, klass if klass.is_a? Hash
64:       name, klass = default_store_name, name if klass.nil?
65: 
66:       raise StoreExists, "#{name} store already setup" if @stores.has_key?(name)
67: 
68:       @stores[name] = (AdhocStore === klass) ? klass : klass.new(opts)
69:     end
setup(&blk) click to toggle source
    # File lib/merb-cache/cache.rb, line 9
 9:     def self.setup(&blk)
10:       if Merb::BootLoader.finished?(Merb::BootLoader::BeforeAppLoads)
11:         instance_eval(&blk) unless blk.nil?
12:       else
13:         Merb::BootLoader.before_app_loads do
14:           instance_eval(&blk) unless blk.nil?
15:         end
16:       end
17:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.