class HTTParty::Icebox::Store::MemoryStore

Public Class Methods

new(options={}) click to toggle source
# File lib/rotten-party/httparty_icebox.rb, line 173
def initialize(options={})
  super; @store = {}; self
end

Public Instance Methods

exists?(key) click to toggle source
# File lib/rotten-party/httparty_icebox.rb, line 185
def exists?(key)
  !@store[key].nil?
end
get(key) click to toggle source
# File lib/rotten-party/httparty_icebox.rb, line 180
def get(key)
  data = @store[key][1]
  Cache.logger.info("Cache: #{data.nil? ? "miss" : "hit"} (#{key})")
  data
end
set(key, value) click to toggle source
# File lib/rotten-party/httparty_icebox.rb, line 176
def set(key, value)
  Cache.logger.info("Cache: set (#{key})")
  @store[key] = [Time.now, value]; true
end
stale?(key) click to toggle source
# File lib/rotten-party/httparty_icebox.rb, line 188
def stale?(key)
  return true unless exists?(key)
  Time.now - created(key) > @timeout
end

Private Instance Methods

created(key) click to toggle source
# File lib/rotten-party/httparty_icebox.rb, line 193
def created(key)
  @store[key][0]
end