Sha256: eb83afe80c3959601fd32f8b623e8cd84b2afc277c8faeff2fb178a40542eb3d
Contents?: true
Size: 516 Bytes
Versions: 2
Compression:
Stored size: 516 Bytes
Contents
require "cachew/adapter" module Cachew # In-memory cache adapter. class Hash < Adapter # @param [#to_hash] store Underlying Hash used for storage def initialize(store = {}) @store = store.to_hash end private # :nodoc: def __set__(key, val, ttl) ttl = 0 >= ttl ? 0 : Time.now.to_i + ttl @store[key] = [val, ttl] end # :nodoc: def __get__(key) val, ttl = @store[key] ttl && (0 == ttl || ttl > Time.now.to_i) ? val : UNDEFINED end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cachew-0.2.1 | lib/cachew/hash.rb |
cachew-0.2.0 | lib/cachew/hash.rb |