Class: Gitlab::Experiment::Cache::Interface
- Inherits:
-
Object
- Object
- Gitlab::Experiment::Cache::Interface
- Defined in:
- lib/gitlab/experiment/cache.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #attr_get(name) ⇒ Object
- #attr_inc(name, amount = 1) ⇒ Object
- #attr_set(name, value) ⇒ Object
- #delete ⇒ Object
-
#initialize(experiment, store) ⇒ Interface
constructor
A new instance of Interface.
- #read ⇒ Object
- #write(value = nil) ⇒ Object
Constructor Details
#initialize(experiment, store) ⇒ Interface
Returns a new instance of Interface.
13 14 15 16 17 |
# File 'lib/gitlab/experiment/cache.rb', line 13 def initialize(experiment, store) @experiment = experiment @store = store @key = experiment.cache_key end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
11 12 13 |
# File 'lib/gitlab/experiment/cache.rb', line 11 def key @key end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
11 12 13 |
# File 'lib/gitlab/experiment/cache.rb', line 11 def store @store end |
Instance Method Details
#attr_get(name) ⇒ Object
31 32 33 |
# 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) ⇒ Object
39 40 41 |
# 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) ⇒ Object
35 36 37 |
# File 'lib/gitlab/experiment/cache.rb', line 35 def attr_set(name, value) store.write(@experiment.cache_key(name, suffix: :attrs), value) end |
#delete ⇒ Object
27 28 29 |
# File 'lib/gitlab/experiment/cache.rb', line 27 def delete store.delete(key) end |
#read ⇒ Object
19 20 21 |
# File 'lib/gitlab/experiment/cache.rb', line 19 def read store.read(key) end |
#write(value = nil) ⇒ Object
23 24 25 |
# File 'lib/gitlab/experiment/cache.rb', line 23 def write(value = nil) store.write(key, value || @experiment.variant.name) end |