blob: dc13bb927e6cdb2d67dc436833fa2777f563a995 (
plain)
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
|
# frozen_string_literal: true
# Interface to the Redis-backed cache store to keep track of complete cache keys
# for a ReactiveCache resource.
module Gitlab
class ReactiveCacheSetCache < Gitlab::SetCache
attr_reader :expires_in
def initialize(expires_in: 10.minutes)
@expires_in = expires_in
end
def clear_cache!(key)
use_pipeline = ::Feature.enabled?(:use_pipeline_over_multikey)
with do |redis|
keys = read(key).map { |value| "#{cache_namespace}:#{value}" }
keys << cache_key(key)
Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do
redis.pipelined do |pipeline|
if use_pipeline
keys.each { |key| pipeline.unlink(key) }
else
keys.each_slice(1000) { |subset| pipeline.unlink(*subset) }
end
end
end
end
end
end
end
|