Class: Rack::Cache::MetaStore::Redis

Inherits:
Rack::Cache::MetaStore show all
Includes:
RedisBase
Defined in:
lib/rack/cache/redis_metastore.rb

Constant Summary

Constants inherited from Rack::Cache::MetaStore

REDIS

Instance Method Summary collapse

Methods included from RedisBase

included, #initialize, #open

Instance Method Details

#purge(key) ⇒ Object



22
23
24
25
# File 'lib/rack/cache/redis_metastore.rb', line 22

def purge(key)
  cache.del(hexdigest(key))
  nil
end

#read(key) ⇒ Object



13
14
15
# File 'lib/rack/cache/redis_metastore.rb', line 13

def read(key)
  cache.get(hexdigest(key)) || []
end

#write(key, entries, ttl = 0) ⇒ Object



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

def write(key, entries, ttl=0)
  ttl = ttl.to_i.zero? ? default_ttl : ttl
  cache.setex(hexdigest(key), ttl, entries)
end