Class: Rack::Cache::MetaStore::Redis
- Inherits:
-
RedisBase
- Object
- Rack::Cache::MetaStore
- RedisBase
- Rack::Cache::MetaStore::Redis
- Defined in:
- lib/rack/cache/redis_metastore.rb
Constant Summary
Constants inherited from Rack::Cache::MetaStore
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
The Redis instance used to communicated with the Redis daemon.
Instance Method Summary collapse
-
#initialize(server, options = {}) ⇒ Redis
constructor
A new instance of Redis.
- #purge(key) ⇒ Object
- #read(key) ⇒ Object
- #write(key, entries, ttl = 0) ⇒ Object
Methods inherited from RedisBase
Constructor Details
Instance Attribute Details
#cache ⇒ Object (readonly)
The Redis instance used to communicated with the Redis daemon.
23 24 25 |
# File 'lib/rack/cache/redis_metastore.rb', line 23 def cache @cache end |
Instance Method Details
#purge(key) ⇒ Object
38 39 40 41 |
# File 'lib/rack/cache/redis_metastore.rb', line 38 def purge(key) cache.del(hexdigest(key)) nil end |
#read(key) ⇒ Object
29 30 31 |
# File 'lib/rack/cache/redis_metastore.rb', line 29 def read(key) cache.get(hexdigest(key)) || [] end |
#write(key, entries, ttl = 0) ⇒ Object
33 34 35 36 |
# File 'lib/rack/cache/redis_metastore.rb', line 33 def write(key, entries, ttl=0) ttl = ::Redis::Rack::Cache::DEFAULT_TTL if ttl.zero? cache.setex(hexdigest(key), ttl, entries) end |