Parent

Rack::Cache::Storage

Maintains a collection of MetaStore and EntityStore instances keyed by URI. A single instance of this class can be used across a single process to ensure that only a single instance of a backing store is created per unique storage URI.

Public Class Methods

instance() click to toggle source
    # File lib/rack/cache/storage.rb, line 57
57:     def self.instance
58:       @@singleton_instance
59:     end
new() click to toggle source
    # File lib/rack/cache/storage.rb, line 12
12:     def initialize
13:       @metastores = {}
14:       @entitystores = {}
15:     end

Public Instance Methods

clear() click to toggle source
    # File lib/rack/cache/storage.rb, line 25
25:     def clear
26:       @metastores.clear
27:       @entitystores.clear
28:       nil
29:     end
resolve_entitystore_uri(uri) click to toggle source
    # File lib/rack/cache/storage.rb, line 21
21:     def resolve_entitystore_uri(uri)
22:       @entitystores[uri.to_s] ||= create_store(EntityStore, uri)
23:     end
resolve_metastore_uri(uri) click to toggle source
    # File lib/rack/cache/storage.rb, line 17
17:     def resolve_metastore_uri(uri)
18:       @metastores[uri.to_s] ||= create_store(MetaStore, uri)
19:     end

Private Instance Methods

create_store(type, uri) click to toggle source
    # File lib/rack/cache/storage.rb, line 32
32:     def create_store(type, uri)
33:       if uri.respond_to?(:scheme) || uri.respond_to?(:to_str)
34:         uri = URI.parse(uri) unless uri.respond_to?(:scheme)
35:         if type.const_defined?(uri.scheme.upcase)
36:           klass = type.const_get(uri.scheme.upcase)
37:           klass.resolve(uri)
38:         else
39:           fail "Unknown storage provider: #{uri.to_s}"
40:         end
41:       else
42:         # hack in support for passing a Dalli::Client or Memcached object
43:         # as the storage URI.
44:         case
45:         when defined?(::Dalli) && uri.kind_of?(::Dalli::Client)
46:           type.const_get(:Dalli).resolve(uri)
47:         when defined?(::Memcached) && uri.respond_to?(:stats)
48:           type.const_get(:MemCached).resolve(uri)
49:         else
50:           fail "Unknown storage provider: #{uri.to_s}"
51:         end
52:       end
53:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.