Sha256: d239648d92890ca6fc6a050ed2d6d061c3940973dda2ec6ea6a13aaa89917cbb
Contents?: true
Size: 1.39 KB
Versions: 3
Compression:
Stored size: 1.39 KB
Contents
class Cachetastic::Stores::Memcache < Cachetastic::Stores::Base def setup self.conn = MemCache.new(self.servers, self.store_options.merge({:namespace => self.namespace})) self.version = self.get_version(self.name) end def set(key, value, expiry = 0) self.conn.set(key, value, expiry) end def delete(key, delay = 0) self.conn.delete(key, delay) end def get(key) self.conn.get(key) end def expire_all self.increment_version(self.name) end def inspect self.conn.inspect + " <version: #{self.version}> #{self.conn.stats.inspect}" end def namespace v = self.get_version(self.name) return "#{name}.#{v}" end def valid? begin return (self.conn.active? && self.version == self.get_version(self.name)) rescue Exception => e puts e.message puts e.backtrace.join("\n") return false end end protected attr_accessor :conn attr_accessor :version def ns_versions ivar_cache do ns_conn = MemCache.new(self.servers, self.store_options.merge({:namespace => :namespace_versions})) end end def increment_version(name) name = name.to_s v = get_version(name) self.ns_versions.set(name, v + 1) end def get_version(name) name = name.to_s v = self.ns_versions.get(name) if v.nil? self.ns_versions.set(name, 1) v = 1 end v end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cachetastic-1.0.7 | lib/stores/cachetastic_stores_memcache.rb |
cachetastic-1.0.8 | lib/stores/cachetastic_stores_memcache.rb |
cachetastic-1.1.3 | lib/stores/cachetastic_stores_memcache.rb |