Sha256: b5f165d127af214f903042407d9fec8d08a96230ef27b3acb5625a889fdada2d
Contents?: true
Size: 1.08 KB
Versions: 18
Compression:
Stored size: 1.08 KB
Contents
begin require "localmemcache" rescue LoadError puts "You need the localmemcache gem to use the LMC moneta store" exit end module Moneta class Expiration def initialize(hash) @hash = hash end def [](key) @hash["#{key}__!__expiration"] end def []=(key, value) @hash["#{key}__!__expiration"] = value end def delete(key) key = "#{key}__!__expiration" value = @hash[key] @hash.delete(key) value end end class LMC include Defaults module Implementation def initialize(options = {}) @hash = LocalMemCache.new(:filename => options[:filename]) @expiration = Expiration.new(@hash) end def [](key) @hash[key] end def []=(key, value) @hash[key] = value end def clear() @hash.clear end def key?(key) @hash.keys.include?(key) end def delete(key) value = @hash[key] @hash.delete(key) value end end include Implementation include StringExpires end end
Version data entries
18 entries across 18 versions & 9 rubygems