See ActiveSupport::Cache::Store for documentation.
These options mean something to all cache implementations. Individual cache implementations may support additional options.
# File lib/active_support/cache.rb, line 77
77: def self.expand_cache_key(key, namespace = nil)
78: expanded_cache_key = namespace ? "#{namespace}/" : ""
79:
80: prefix = ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]
81: if prefix
82: expanded_cache_key << "#{prefix}/"
83: end
84:
85: expanded_cache_key <<
86: if key.respond_to?(:cache_key)
87: key.cache_key
88: elsif key.is_a?(Array)
89: if key.size > 1
90: key.collect { |element| expand_cache_key(element) }.to_param
91: else
92: key.first.to_param
93: end
94: elsif key
95: key.to_param
96: end.to_s
97:
98: expanded_cache_key
99: end
Creates a new CacheStore object according to the given options.
If no arguments are passed to this method, then a new ActiveSupport::Cache::MemoryStore object will be returned.
If you pass a Symbol as the first argument, then a corresponding cache store class under the ActiveSupport::Cache namespace will be created. For example:
ActiveSupport::Cache.lookup_store(:memory_store) # => returns a new ActiveSupport::Cache::MemoryStore object ActiveSupport::Cache.lookup_store(:mem_cache_store) # => returns a new ActiveSupport::Cache::MemCacheStore object
Any additional arguments will be passed to the corresponding cache store class’s constructor:
ActiveSupport::Cache.lookup_store(:file_store, "/tmp/cache")
# => same as: ActiveSupport::Cache::FileStore.new("/tmp/cache")
If the first argument is not a Symbol, then it will simply be returned:
ActiveSupport::Cache.lookup_store(MyOwnCacheStore.new) # => returns MyOwnCacheStore.new
# File lib/active_support/cache.rb, line 55
55: def self.lookup_store(*store_option)
56: store, *parameters = *Array.wrap(store_option).flatten
57:
58: case store
59: when Symbol
60: store_class_name = store.to_s.camelize
61: store_class =
62: begin
63: require "active_support/cache/#{store}"
64: rescue LoadError => e
65: raise "Could not find cache store adapter for #{store} (#{e})"
66: else
67: ActiveSupport::Cache.const_get(store_class_name)
68: end
69: store_class.new(*parameters)
70: when nil
71: ActiveSupport::Cache::MemoryStore.new
72: else
73: store
74: end
75: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.