Class: Gitlab::EtagCaching::Store
- Inherits:
-
Object
- Object
- Gitlab::EtagCaching::Store
- Defined in:
- lib/gitlab/etag_caching/store.rb
Constant Summary collapse
- InvalidKeyError =
Class.new(StandardError)
- EXPIRY_TIME =
20.minutes
- SHARED_STATE_NAMESPACE =
'etag:'
Instance Method Summary collapse
Instance Method Details
#get(key) ⇒ Object
11 12 13 |
# File 'lib/gitlab/etag_caching/store.rb', line 11 def get(key) with_redis { |redis| redis.get(redis_shared_state_key(key)) } end |
#touch(*keys, only_if_missing: false) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gitlab/etag_caching/store.rb', line 15 def touch(*keys, only_if_missing: false) = keys.map { generate_etag } Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do with_redis do |redis| redis.pipelined do |pipeline| keys.each_with_index do |key, i| pipeline.set(redis_shared_state_key(key), [i], ex: EXPIRY_TIME, nx: only_if_missing) end end end end keys.size > 1 ? : .first end |