class Lux::Cache::MemoryCache
Public Instance Methods
delete(key)
click to toggle source
# File lib/lux/cache/lib/memory.rb, line 27 def delete key @@lock.synchronize do @@ram_cache.delete(key) end end
fetch(key, ttl=nil) { || ... }
click to toggle source
# File lib/lux/cache/lib/memory.rb, line 21 def fetch key, ttl=nil data = get key return data if data set(key, yield, ttl) end
get(key)
click to toggle source
# File lib/lux/cache/lib/memory.rb, line 13 def get key if ttl_check = @@ttl_cache[key] return nil if ttl_check < Time.now.to_i end @@ram_cache[key] end
get_multi(*args)
click to toggle source
# File lib/lux/cache/lib/memory.rb, line 33 def get_multi(*args) @@ram_cache.select{ |k,v| args.index(k) } end
set(key, data, ttl=nil)
click to toggle source
# File lib/lux/cache/lib/memory.rb, line 6 def set key, data, ttl=nil @@lock.synchronize do @@ttl_cache[key] = Time.now.to_i + ttl if ttl @@ram_cache[key] = data end end