Strategy store that uses SHA1 hex of base cache key and parameters as cache key.
It is good for caching of expensive search queries that use multiple parameters passed via query string of request.
# File lib/merb-cache/stores/strategy/sha1_store.rb, line 50 50: def delete(key, parameters = {}) 51: @stores.map {|c| c.delete(digest(key, parameters))}.any? 52: end
# File lib/merb-cache/stores/strategy/sha1_store.rb, line 54 54: def delete_all! 55: @stores.map {|c| c.delete_all! }.all? 56: end
# File lib/merb-cache/stores/strategy/sha1_store.rb, line 58 58: def digest(key, parameters = {}) 59: @map[[key, parameters]] ||= Digest::SHA1.hexdigest("#{key}#{parameters.to_sha2}") 60: end
# File lib/merb-cache/stores/strategy/sha1_store.rb, line 46 46: def exists?(key, parameters = {}) 47: @stores.capture_first {|c| c.exists?(digest(key, parameters))} 48: end
# File lib/merb-cache/stores/strategy/sha1_store.rb, line 42 42: def fetch(key, parameters = {}, conditions = {}, &blk) 43: read(key, parameters) || (writable?(key, parameters, conditions) && @stores.capture_first {|c| c.fetch(digest(key, parameters), {}, conditions, &blk)}) 44: end
# File lib/merb-cache/stores/strategy/sha1_store.rb, line 26 26: def read(key, parameters = {}) 27: @stores.capture_first {|c| c.read(digest(key, parameters))} 28: end
# File lib/merb-cache/stores/strategy/sha1_store.rb, line 18 18: def writable?(key, parameters = {}, conditions = {}) 19: case key 20: when String, Numeric, Symbol 21: @stores.any? {|c| c.writable?(digest(key, parameters), {}, conditions)} 22: else nil 23: end 24: end
# File lib/merb-cache/stores/strategy/sha1_store.rb, line 30 30: def write(key, data = nil, parameters = {}, conditions = {}) 31: if writable?(key, parameters, conditions) 32: @stores.capture_first {|c| c.write(digest(key, parameters), data, {}, conditions)} 33: end 34: end
# File lib/merb-cache/stores/strategy/sha1_store.rb, line 36 36: def write_all(key, data = nil, parameters = {}, conditions = {}) 37: if writable?(key, parameters, conditions) 38: @stores.map {|c| c.write_all(digest(key, parameters), data, {}, conditions)}.all? 39: end 40: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.