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

Inherits:
RedisBase show all
Defined in:
lib/rack/cache/redis_metastore.rb

Constant Summary

Constants inherited from Rack::Cache::MetaStore

REDIS

Instance Attribute Summary

Attributes inherited from RedisBase

#cache

Instance Method Summary collapse

Methods inherited from RedisBase

resolve

Constructor Details

#initialize(server, options = {}) ⇒ Redis

Returns a new instance of Redis.



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

def initialize(server, options = {})
  @cache = ::Redis::Factory.create server
end

Instance Method Details

#purge(key) ⇒ Object



33
34
35
36
# File 'lib/rack/cache/redis_metastore.rb', line 33

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

#read(key) ⇒ Object



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

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

#write(key, entries) ⇒ Object



28
29
30
31
# File 'lib/rack/cache/redis_metastore.rb', line 28

def write(key, entries)
  key = hexdigest(key)
  cache.set(key, entries)
end