Class: Gitlab::Redis::ClusterStore

Inherits:
Redis::Cluster
  • Object
show all
Includes:
Redis::Store::Interface
Defined in:
lib/gitlab/redis/cluster_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ClusterStore

Returns a new instance of ClusterStore.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/redis/cluster_store.rb', line 14

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

  @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

  _remove_unsupported_options(options)
  super(options)

  _extend_marshalling
  _extend_namespace orig_options
end

Instance Method Details

#set(key, value, options = nil) ⇒ Object

copies ::Redis::Store::Ttl implementation in a redis-v5 compatible manner



32
33
34
35
36
37
38
39
# File 'lib/gitlab/redis/cluster_store.rb', line 32

def set(key, value, options = nil)
  ttl = get_ttl(options)
  if ttl
    setex(key, ttl.to_i, value, raw: true)
  else
    super(key, value)
  end
end

#setnx(key, value, options = nil) ⇒ Object

copies ::Redis::Store::Ttl implementation in a redis-v5 compatible manner



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/gitlab/redis/cluster_store.rb', line 42

def setnx(key, value, options = nil)
  ttl = get_ttl(options)
  if ttl
    multi do |m|
      m.setnx(key, value)
      m.expire(key, ttl)
    end
  else
    super(key, value)
  end
end