Class: Redis::Store

Inherits:
Redis
  • Object
show all
Includes:
Interface, RedisVersion, Ttl
Defined in:
lib/redis/store.rb,
lib/redis/store/ttl.rb,
lib/redis/store/factory.rb,
lib/redis/store/version.rb,
lib/redis/store/interface.rb,
lib/redis/store/namespace.rb,
lib/redis/store/redis_version.rb,
lib/redis/store/serialization.rb

Defined Under Namespace

Modules: Interface, Namespace, RedisVersion, Serialization, Ttl Classes: Factory

Constant Summary collapse

VERSION =
'1.11.0'

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Ttl

#set, #setnx

Methods included from Interface

#get, #set, #setex, #setnx

Methods included from RedisVersion

#redis_version, #supports_redis_version?

Constructor Details

#initialize(options = {}) ⇒ Store

Returns a new instance of Store.



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
# File 'lib/redis/store.rb', line 16

def initialize(options = {})
  orig_options = options.dup

  _remove_unsupported_options(options)
  # The options here is updated
  super(options)

  unless orig_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 = orig_options.key?(:serializer) ? orig_options.delete(:serializer) : Marshal

  unless orig_options[:marshalling].nil?
    # `marshalling` only used here, might not be supported in `super`
    @serializer = orig_options.delete(:marshalling) ? Marshal : nil
  end

  _extend_marshalling
  _extend_namespace orig_options
end

Class Method Details

.redis_client_defined?Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
# File 'lib/redis/store/version.rb', line 5

def self.redis_client_defined?
  # Doesn't work if declared as constant
  # due to unpredictable gem loading order
  # https://github.com/redis-rb/redis-client
  defined?(::RedisClient::VERSION)
end

Instance Method Details

#locationObject



53
54
55
56
57
58
59
60
61
# File 'lib/redis/store.rb', line 53

def location
  if @client.path
    @client.path
  else
    h = @client.host
    h = "[#{h}]" if h.include?(":")
    "#{h}:#{@client.port}"
  end
end

#reconnectObject



45
46
47
# File 'lib/redis/store.rb', line 45

def reconnect
  @client.reconnect
end

#to_sObject



49
50
51
# File 'lib/redis/store.rb', line 49

def to_s
  "Redis Client connected to #{location} against DB #{@client.db}"
end