Class: Gitlab::Redis::ClusterStore
- Inherits:
-
Redis::Cluster
- Object
- Redis::Cluster
- Gitlab::Redis::ClusterStore
- Includes:
- Redis::Store::Interface
- Defined in:
- lib/gitlab/redis/cluster_store.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ClusterStore
constructor
A new instance of ClusterStore.
-
#set(key, value, options = nil) ⇒ Object
copies ::Redis::Store::Ttl implementation in a redis-v5 compatible manner.
-
#setnx(key, value, options = nil) ⇒ Object
copies ::Redis::Store::Ttl implementation in a redis-v5 compatible manner.
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( = {}) = .dup @serializer = .key?(:serializer) ? .delete(:serializer) : Marshal unless [:marshalling].nil? # `marshalling` only used here, might not be supported in `super` @serializer = .delete(:marshalling) ? Marshal : nil end () super() _extend_marshalling _extend_namespace 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, = nil) ttl = get_ttl() 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, = nil) ttl = get_ttl() if ttl multi do |m| m.setnx(key, value) m.expire(key, ttl) end else super(key, value) end end |