Class: ActiveSupport::Cache::EhcacheStore
Instance Attribute Summary
#cache_manager
Instance Method Summary
collapse
-
#clear(options = nil) ⇒ Object
-
#decrement(name, amount = 1, options = nil) ⇒ Object
-
#delete(key, options = nil) ⇒ Object
-
#delete_matched(matcher, options = nil) ⇒ Object
-
#exist?(key, options = nil) ⇒ Boolean
-
#increment(name, amount = 1, options = nil) ⇒ Object
-
#initialize(*args) ⇒ EhcacheStore
constructor
A new instance of EhcacheStore.
-
#keys ⇒ Object
-
#read(key, options = nil) ⇒ Object
-
#stats ⇒ Object
-
#write(key, value, options = {}) ⇒ Object
#create_cache, #create_cache_manager, #default_cache_name
Constructor Details
Returns a new instance of EhcacheStore.
10
11
12
13
|
# File 'lib/active_support/ehcache_store.rb', line 10
def initialize(options = {})
super() @ehcache = self.create_cache
end
|
Instance Method Details
#clear(options = nil) ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/active_support/ehcache_store.rb', line 50
def clear
@ehcache.clear
true
rescue Exception => e
logger.error("EhcacheError (#{e}): #{e.message}")
false
end
|
#decrement(name, amount = 1, options = nil) ⇒ Object
25
26
27
28
29
|
# File 'lib/active_support/cache/ehcache_store.rb', line 25
def decrement(name, amount = 1, options = nil) @ehcache.compare_and_swap(name) { |current_value|
current_value - amount
}
end
|
#delete(key, options = nil) ⇒ Object
30
31
32
33
34
35
|
# File 'lib/active_support/ehcache_store.rb', line 30
def delete(key, options = nil)
@ehcache.remove(key)
rescue Exception => e
logger.error("EhcacheError (#{e}): #{e.message}")
false
end
|
#delete_matched(matcher, options = nil) ⇒ Object
45
46
47
48
|
# File 'lib/active_support/ehcache_store.rb', line 45
def delete_matched(matcher, options = nil)
super
raise "Not supported by Ehcache"
end
|
#exist?(key, options = nil) ⇒ Boolean
41
42
43
|
# File 'lib/active_support/ehcache_store.rb', line 41
def exist?(key, options = nil)
@ehcache.exist?(key)
end
|
#increment(name, amount = 1, options = nil) ⇒ Object
19
20
21
22
23
|
# File 'lib/active_support/cache/ehcache_store.rb', line 19
def increment(name, amount = 1, options = nil) @ehcache.compare_and_swap(name) { |current_value|
current_value + amount
}
end
|
#keys ⇒ Object
37
38
39
|
# File 'lib/active_support/ehcache_store.rb', line 37
def keys
@ehcache.keys
end
|
#read(key, options = nil) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/active_support/ehcache_store.rb', line 15
def read(key, options = nil)
@ehcache[key]
rescue Ehcache::EhcacheError => e
logger.error("EhcacheError (#{e}): #{e.message}")
false
end
|
#stats ⇒ Object
35
36
37
|
# File 'lib/active_support/cache/ehcache_store.rb', line 35
def stats
@ehcache.statistics
end
|
#write(key, value, options = {}) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/active_support/ehcache_store.rb', line 22
def write(key, value, options = {})
@ehcache.put(key, value, options)
true
rescue Ehcache::EhcacheError => e
logger.error("EhcacheError (#{e}): #{e.message}")
false
end
|