Class: Ehcache::ActiveSupportStore

Inherits:
ActiveSupport::Cache::Store
  • Object
show all
Defined in:
lib/ehcache/active_support_store.rb

Direct Known Subclasses

ActiveSupport::Cache::EhcacheStore

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cache_managerObject (readonly)

Returns the value of attribute cache_manager.



19
20
21
# File 'lib/ehcache/active_support_store.rb', line 19

def cache_manager
  @cache_manager
end

Instance Method Details

#create_cache(options = {}) ⇒ Object



33
34
35
36
# File 'lib/ehcache/active_support_store.rb', line 33

def create_cache(options = {})
  create_cache_manager(options) if @cache_manager.nil?
  @cache_manager.cache(options[:cache_name] || default_cache_name)
end

#create_cache_manager(options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ehcache/active_support_store.rb', line 21

def create_cache_manager(options = {})
  config_dir = self.class.config_directory
  config = if options[:ehcache_config]
    File.expand_path(File.join(config_dir, options[:ehcache_config]))
  else
    Ehcache::Config::Configuration.find(config_dir) if config_dir
  end
  # Ehcache will use the failsafe configuration if nothing is passed in
  # Note: .create is a factory method
  @cache_manager = Ehcache::CacheManager.create(config)
end

#default_cache_nameObject



38
39
40
# File 'lib/ehcache/active_support_store.rb', line 38

def default_cache_name
  self.class.default_cache_name || 'app_cache'
end