Sha256: 1fbd1c3a8c9389586d61d787af618b054ca5421e5b9d7a827b5cd12ffdc32edb
Contents?: true
Size: 649 Bytes
Versions: 5
Compression:
Stored size: 649 Bytes
Contents
class APICache class MemoryStore < APICache::AbstractStore def initialize APICache.logger.debug "Using memory store" @cache = {} true end def set(key, value) APICache.logger.debug("cache: set (#{key})") @cache[key] = [Time.now, value] true end def get(key) data = @cache[key][1] APICache.logger.debug("cache: #{data.nil? ? "miss" : "hit"} (#{key})") data end def exists?(key) !@cache[key].nil? end def expired?(key, timeout) Time.now - created(key) > timeout end private def created(key) @cache[key][0] end end end
Version data entries
5 entries across 5 versions & 2 rubygems