Class: ActiveSupport::Cache::RedisStore

Inherits:
Store
  • Object
show all
Includes:
Redis::ClientHelper
Defined in:
lib/active_support/cache/redis_store.rb

Instance Method Summary collapse

Methods included from Redis::ClientHelper

included

Constructor Details

#initialize(*options) ⇒ RedisStore

Returns a new instance of RedisStore.



5
6
7
8
9
# File 'lib/active_support/cache/redis_store.rb', line 5

def initialize(*options)
  options = options.extract_options!
  super(options)
  extend Strategy::LocalCache
end

Instance Method Details

#clear(options = nil) ⇒ Object

Clear the entire cache on server. This method should be used with care when shared cache is being used.



20
21
22
# File 'lib/active_support/cache/redis_store.rb', line 20

def clear(options = nil)
  redis.flushdb
end

#read_multi(*names) ⇒ Object

Reads multiple values from the cache using a single call to the servers for all keys.



13
14
15
16
# File 'lib/active_support/cache/redis_store.rb', line 13

def read_multi(*names)
  values = redis.mget *names
  values.map{ |v| Redis::Marshal.load(v) }
end