Sha256: e35ffd02583ab2edbadb035e52d009879ab9c958e0133d214c331be6ed7da8fd
Contents?: true
Size: 1009 Bytes
Versions: 6
Compression:
Stored size: 1009 Bytes
Contents
# An adapter/store that keeps objects in local memory. This is great for development/testing, # but probably shouldn't be put into production. # It's also a very good example of how to write a adapter. class Cachetastic::Adapters::LocalMemory < Cachetastic::Adapters::Base attr_accessor :local_store def valid? true end def setup self.local_store = {} end def expire_all self.local_store = {} end # See Cachetastic::Adapters::Base def get(key) so = self.local_store[key.to_s] if so if so.invalid? self.delete(key) return nil end return so.value end return nil end def set(key, value, expiry = 0) self.local_store[key.to_s] = Cachetastic::Adapters::StoreObject.new(key.to_s, value, expiry) end def delete(key, delay = 0) if delay <= 0 self.local_store.delete(key.to_s) else so = self.get(key) if so self.set(so.key, so.value, delay) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems