Sha256: b28995947f47b765fddeaa2f8a8acdba6925cbd931303a6eb431777c3c2dfa35
Contents?: true
Size: 1.69 KB
Versions: 2
Compression:
Stored size: 1.69 KB
Contents
require 'ehcache/rails/ehcache_rails_common' module ActiveSupport module Cache # Rails 3 cache store implementation which stores data in Ehcache: # http://www.ehcache.org/ class EhcacheStore < Store include Ehcache::Rails def initialize(*args) args = args.flatten options = args.extract_options! super(*options) @ehcache = self.create_cache # This comes from the Ehcache::Rails mixin. extend Strategy::LocalCache end def increment(name, amount = 1, options = nil) # :nodoc: @ehcache.compare_and_swap(name) { |current_value| current_value + amount } end def decrement(name, amount = 1, options = nil) # :nodoc: @ehcache.compare_and_swap(name) { |current_value| current_value - amount } end def clear(options = nil) @ehcache.remove_all end def stats @ehcache.statistics end protected # Read an entry from the cache. def read_entry(key, options) # :nodoc: @ehcache[key] rescue Ehcache::EhcacheError => e logger.error("EhcacheError (#{e}): #{e.message}") false end # Write an entry to the cache. def write_entry(key, entry, options) # :nodoc: @ehcache.put(key, entry, options) true rescue Ehcache::EhcacheError => e logger.error("EhcacheError (#{e}): #{e.message}") false end # Delete an entry from the cache. def delete_entry(key, options) # :nodoc: @ehcache.remove(key) rescue Exception => e logger.error("EhcacheError (#{e}): #{e.message}") false end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
jruby-ehcache-rails2-1.0.0 | lib/active_support/cache/ehcache_store.rb |
jruby-ehcache-rails3-1.0.0 | lib/active_support/cache/ehcache_store.rb |