Module: Rack::Dedos::Cache::Hash

Defined in:
lib/rack/dedos/cache.rb

Instance Method Summary collapse

Instance Method Details

#get(key) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/rack/dedos/cache.rb', line 25

def get(key)
  if (value, created_at = store[key])
    if !@expires_in || @expires_in >= timestamp - created_at
      value
    else
      store.delete(key)
      nil
    end
  end
end

#set(key, value) ⇒ Object



21
22
23
# File 'lib/rack/dedos/cache.rb', line 21

def set(key, value)
  store[key] = [value, timestamp]
end

#storeObject



17
18
19
# File 'lib/rack/dedos/cache.rb', line 17

def store
  @store ||= {}
end