1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
require 'redis'
require 'redis/store/factory'
require 'redis/distributed_store'
require 'redis/store/namespace'
require 'redis/store/serialization'
require 'redis/store/version'
require 'redis/store/ttl'
require 'redis/store/interface'
class Redis
class Store < self
include Ttl, Interface
def initialize(options = { })
super
unless options[:marshalling].nil?
puts %(
DEPRECATED: You are passing the :marshalling option, which has been
replaced with `serializer: Marshal` to support pluggable serialization
backends. To disable serialization (much like disabling marshalling),
pass `serializer: nil` in your configuration.
The :marshalling option will be removed for redis-store 2.0.
)
end
@serializer = options.key?(:serializer) ? options[:serializer] : Marshal
unless options[:marshalling].nil?
@serializer = options[:marshalling] ? Marshal : nil
end
_extend_marshalling options
_extend_namespace options
end
def reconnect
@client.reconnect
end
def to_s
h = @client.host
"Redis Client connected to #{/:/ =~ h ? '['+h+']' : h}:#{@client.port} against DB #{@client.db}"
end
private
def _extend_marshalling(options)
extend Serialization unless @serializer.nil?
end
def _extend_namespace(options)
@namespace = options[:namespace]
extend Namespace if @namespace
end
end
end
|