Class: Gitlab::EtagCaching::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/etag_caching/store.rb

Constant Summary collapse

EXPIRY_TIME =
20.minutes
SHARED_STATE_NAMESPACE =
'etag:'

Instance Method Summary collapse

Instance Method Details

#get(key) ⇒ Object


9
10
11
# File 'lib/gitlab/etag_caching/store.rb', line 9

def get(key)
  Gitlab::Redis::SharedState.with { |redis| redis.get(redis_shared_state_key(key)) }
end

#touch(key, only_if_missing: false) ⇒ Object


13
14
15
16
17
18
19
20
21
# File 'lib/gitlab/etag_caching/store.rb', line 13

def touch(key, only_if_missing: false)
  etag = generate_etag

  Gitlab::Redis::SharedState.with do |redis|
    redis.set(redis_shared_state_key(key), etag, ex: EXPIRY_TIME, nx: only_if_missing)
  end

  etag
end