class Gitlab::Experiment::Cache::Interface

Attributes

key[R]
store[R]

Public Class Methods

new(experiment, store) click to toggle source
# File lib/gitlab/experiment/cache.rb, line 13
def initialize(experiment, store)
  @experiment = experiment
  @store = store
  @key = experiment.cache_key
end

Public Instance Methods

attr_get(name) click to toggle source
# File lib/gitlab/experiment/cache.rb, line 31
def attr_get(name)
  store.read(@experiment.cache_key(name, suffix: :attrs))
end
attr_inc(name, amount = 1) click to toggle source
# File lib/gitlab/experiment/cache.rb, line 39
def attr_inc(name, amount = 1)
  store.increment(@experiment.cache_key(name, suffix: :attrs), amount)
end
attr_set(name, value) click to toggle source
# File lib/gitlab/experiment/cache.rb, line 35
def attr_set(name, value)
  store.write(@experiment.cache_key(name, suffix: :attrs), value)
end
delete() click to toggle source
# File lib/gitlab/experiment/cache.rb, line 27
def delete
  store.delete(key)
end
read() click to toggle source
# File lib/gitlab/experiment/cache.rb, line 19
def read
  store.read(key)
end
write(value = nil) click to toggle source
# File lib/gitlab/experiment/cache.rb, line 23
def write(value = nil)
  store.write(key, value || @experiment.variant.name)
end