Module ActiveSupport::Cache
In: vendor/rails/activesupport/lib/active_support/cache.rb
vendor/rails/activesupport/lib/active_support/cache/compressed_mem_cache_store.rb
vendor/rails/activesupport/lib/active_support/cache/drb_store.rb
vendor/rails/activesupport/lib/active_support/cache/file_store.rb
vendor/rails/activesupport/lib/active_support/cache/mem_cache_store.rb
vendor/rails/activesupport/lib/active_support/cache/memory_store.rb
vendor/rails/activesupport/lib/active_support/cache/synchronized_memory_store.rb

See ActiveSupport::Cache::Store for documentation.

Methods

Classes and Modules

Class 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

[Source]

    # File vendor/rails/activesupport/lib/active_support/cache.rb, line 46
46:     def self.expand_cache_key(key, namespace = nil)
47:       expanded_cache_key = namespace ? "#{namespace}/" : ""
48: 
49:       if ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]
50:         expanded_cache_key << "#{ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]}/"
51:       end
52: 
53:       expanded_cache_key << case
54:         when key.respond_to?(:cache_key)
55:           key.cache_key
56:         when key.is_a?(Array)
57:           key.collect { |element| expand_cache_key(element) }.to_param
58:         when key
59:           key.to_param
60:         end.to_s
61: 
62:       expanded_cache_key
63:     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

[Source]

    # File vendor/rails/activesupport/lib/active_support/cache.rb, line 31
31:     def self.lookup_store(*store_option)
32:       store, *parameters = *([ store_option ].flatten)
33: 
34:       case store
35:       when Symbol
36:         store_class_name = (store == :drb_store ? "DRbStore" : store.to_s.camelize)
37:         store_class = ActiveSupport::Cache.const_get(store_class_name)
38:         store_class.new(*parameters)
39:       when nil
40:         ActiveSupport::Cache::MemoryStore.new
41:       else
42:         store
43:       end
44:     end

[Validate]