Module: Gitlab::Experiment::Cache
- Included in:
- Gitlab::Experiment
- Defined in:
- lib/gitlab/experiment/cache.rb,
lib/gitlab/experiment/cache/redis_hash_store.rb
Defined Under Namespace
Classes: Interface, RedisHashStore
Instance Method Summary
collapse
Instance Method Details
#cache ⇒ Object
44
45
46
|
# File 'lib/gitlab/experiment/cache.rb', line 44
def cache
@cache ||= Interface.new(self, Configuration.cache)
end
|
#cache_key(key = nil, suffix: nil) ⇒ Object
58
59
60
|
# File 'lib/gitlab/experiment/cache.rb', line 58
def cache_key(key = nil, suffix: nil)
"#{[name, suffix].compact.join('_')}:#{key || context.signature[:key]}"
end
|
#cache_variant(specified = nil, &block) ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'lib/gitlab/experiment/cache.rb', line 48
def cache_variant(specified = nil, &block)
return (specified.presence || yield) unless cache.store
result = migrated_cache_fetch(cache.store, &block)
return result unless specified.present?
cache.write(specified) if result != specified
specified
end
|