Sha256: 748cc681f26a36af23a734f92f33431ce94b1289d8d4a688c392adffcfcd099a
Contents?: true
Size: 748 Bytes
Versions: 28
Compression:
Stored size: 748 Bytes
Contents
module Friendly class Cache class ByID < Cache def store(document) cache.set(cache_key(document.id), document) end alias_method :create, :store alias_method :update, :store def destroy(document) cache.delete(cache_key(document.id)) end def first(query, &block) cache.get(cache_key(query.conditions[:id]), &block) end def all(query, &block) keys = query.conditions[:id].map { |k| cache_key(k) } cache.multiget(keys, &block).values end def satisfies?(query) query.conditions.keys == [:id] end protected def cache_key(id) [klass.name, version, id.to_guid].join("/") end end end end
Version data entries
28 entries across 28 versions & 7 rubygems