Class: Gitlab::ReactiveCacheSetCache
- Defined in:
- lib/gitlab/reactive_cache_set_cache.rb
Instance Attribute Summary collapse
-
#expires_in ⇒ Object
readonly
Returns the value of attribute expires_in.
Instance Method Summary collapse
- #clear_cache!(key) ⇒ Object
-
#initialize(expires_in: 10.minutes) ⇒ ReactiveCacheSetCache
constructor
A new instance of ReactiveCacheSetCache.
Methods inherited from SetCache
#cache_key, #count, #exist?, #expire, #include?, #read, #try_include?, #ttl, #write
Constructor Details
#initialize(expires_in: 10.minutes) ⇒ ReactiveCacheSetCache
Returns a new instance of ReactiveCacheSetCache.
9 10 11 |
# File 'lib/gitlab/reactive_cache_set_cache.rb', line 9 def initialize(expires_in: 10.minutes) @expires_in = expires_in end |
Instance Attribute Details
#expires_in ⇒ Object (readonly)
Returns the value of attribute expires_in.
7 8 9 |
# File 'lib/gitlab/reactive_cache_set_cache.rb', line 7 def expires_in @expires_in end |
Instance Method Details
#clear_cache!(key) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gitlab/reactive_cache_set_cache.rb', line 13 def clear_cache!(key) with do |redis| keys = read(key).map { |value| "#{cache_namespace}:#{value}" } keys << cache_key(key) Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do if Gitlab::Redis::ClusterUtil.cluster?(redis) Gitlab::Redis::ClusterUtil.batch_unlink(keys, redis) else redis.pipelined do |pipeline| keys.each_slice(1000) { |subset| pipeline.unlink(*subset) } end end end end end |