See ActiveSupport::Cache::Store for documentation.
Methods
Classes and Modules
Module ActiveSupport::Cache::StrategyClass ActiveSupport::Cache::CompressedMemCacheStore
Class ActiveSupport::Cache::FileStore
Class ActiveSupport::Cache::MemCacheStore
Class ActiveSupport::Cache::MemoryStore
Class ActiveSupport::Cache::Store
Class ActiveSupport::Cache::SynchronizedMemoryStore
Public Class methods
[ show source ]
# File activesupport/lib/active_support/cache.rb, line 57 57: def self.expand_cache_key(key, namespace = nil) 58: expanded_cache_key = namespace ? "#{namespace}/" : "" 59: 60: if ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"] 61: expanded_cache_key << "#{ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]}/" 62: end 63: 64: expanded_cache_key << case 65: when key.respond_to?(:cache_key) 66: key.cache_key 67: when key.is_a?(Array) 68: key.collect { |element| expand_cache_key(element) }.to_param 69: when key 70: key.to_param 71: end.to_s 72: 73: expanded_cache_key 74: 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(:drb_store) # => returns a new ActiveSupport::Cache::DRbStore 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
[ show source ]
# File activesupport/lib/active_support/cache.rb, line 42 42: def self.lookup_store(*store_option) 43: store, *parameters = *([ store_option ].flatten) 44: 45: case store 46: when Symbol 47: store_class_name = (store == :drb_store ? "DRbStore" : store.to_s.camelize) 48: store_class = ActiveSupport::Cache.const_get(store_class_name) 49: store_class.new(*parameters) 50: when nil 51: ActiveSupport::Cache::MemoryStore.new 52: else 53: store 54: end 55: end