Sha256: 9c6d1e0c3b3be787a9a11ec797e0de64470a55739981c0146f4a0026ba830393
Contents?: true
Size: 582 Bytes
Versions: 3
Compression:
Stored size: 582 Bytes
Contents
class APICache::MemoryStore < APICache::AbstractStore def initialize APICache.logger.log "Using memory store" @cache = {} true end def set(key, value) APICache.logger.log("cache: set (#{key})") @cache[key] = [Time.now, value] true end def get(key) data = @cache[key][1] APICache.logger.log("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
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
mloughran-api_cache-0.1.1 | lib/api_cache/memory_store.rb |
mloughran-api_cache-0.1.2 | lib/api_cache/memory_store.rb |
api_cache-0.1.2 | lib/api_cache/memory_store.rb |