Sha256: 307f02649746ec550d039bc2c0663bb915884f0e81a87e3e7aadabb2c069f965
Contents?: true
Size: 1.81 KB
Versions: 1
Compression:
Stored size: 1.81 KB
Contents
begin require 'ehcache' rescue LoadError => e $stderr.puts "You don't have ehcache installed in your application. Please add it to your Gemfile and run bundle install" raise e end #require 'digest/md5' module ActiveSupport module Cache # A cache store implementation which stores data in Ehcache: # http://www.ehcache.org/ class EhcacheStore < Store def initialize(*args) super(*args) @data = Ehcache::CacheManager.new.cache extend Strategy::LocalCache end def increment(name, amount = 1, options = nil) # :nodoc: if num = @data.get(name) num = num.to_i + amount @data.put(name, num, options) num else nil end end def decrement(name, amount = 1, options = nil) # :nodoc: if num = @data.get(name) num = num.to_i - amount @data.put(name, num, options) num else nil end end def clear(options = nil) @data.remove_all end def stats @data.statistics end protected # Read an entry from the cache. def read_entry(key, options) # :nodoc: @data.get(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: @data.set(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: @data.delete(key) rescue Exception => e logger.error("EhcacheError (#{e}): #{e.message}") false end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jruby-ehcache-rails3-0.5.0 | lib/active_support/cache/ehcache_store.rb |