Class: ActiveSupport::Cache::EhcacheStore
- Inherits:
-
Store
- Object
- Store
- ActiveSupport::Cache::EhcacheStore
- Includes:
- Ehcache::Rails
- Defined in:
- lib/active_support/cache/ehcache_store.rb
Overview
Rails 3 cache store implementation which stores data in Ehcache: http://www.ehcache.org/
Constant Summary
Constants included from Ehcache::Rails
Ehcache::Rails::DEFAULT_RAILS_CACHE_NAME, Ehcache::Rails::RAILS_CONFIG_DIR
Instance Method Summary collapse
- #clear(options = nil) ⇒ Object
-
#decrement(name, amount = 1, options = nil) ⇒ Object
:nodoc:.
-
#increment(name, amount = 1, options = nil) ⇒ Object
:nodoc:.
-
#initialize(*args) ⇒ EhcacheStore
constructor
A new instance of EhcacheStore.
- #stats ⇒ Object
Methods included from Ehcache::Rails
#create_cache, #create_cache_manager
Constructor Details
#initialize(*args) ⇒ EhcacheStore
Returns a new instance of EhcacheStore.
11 12 13 14 15 16 17 |
# File 'lib/active_support/cache/ehcache_store.rb', line 11 def initialize(*args) args = args.flatten = args. super(*) @ehcache = self.create_cache # This comes from the Ehcache::Rails mixin. extend Strategy::LocalCache end |
Instance Method Details
#clear(options = nil) ⇒ Object
31 32 33 |
# File 'lib/active_support/cache/ehcache_store.rb', line 31 def clear( = nil) @ehcache.remove_all end |
#decrement(name, amount = 1, options = nil) ⇒ Object
:nodoc:
25 26 27 28 29 |
# File 'lib/active_support/cache/ehcache_store.rb', line 25 def decrement(name, amount = 1, = nil) # :nodoc: @ehcache.compare_and_swap(name) { |current_value| current_value - amount } end |
#increment(name, amount = 1, options = nil) ⇒ Object
:nodoc:
19 20 21 22 23 |
# File 'lib/active_support/cache/ehcache_store.rb', line 19 def increment(name, amount = 1, = nil) # :nodoc: @ehcache.compare_and_swap(name) { |current_value| current_value + amount } end |
#stats ⇒ Object
35 36 37 |
# File 'lib/active_support/cache/ehcache_store.rb', line 35 def stats @ehcache.statistics end |