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.
11 12 13 14 15 |
# File 'lib/gitlab/experiment/cache.rb', line 11 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.
9 10 11 |
# File 'lib/gitlab/experiment/cache.rb', line 9 def key @key end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
9 10 11 |
# File 'lib/gitlab/experiment/cache.rb', line 9 def store @store end |
Instance Method Details
#attr_get(name) ⇒ Object
29 30 31 |
# File 'lib/gitlab/experiment/cache.rb', line 29 def attr_get(name) store.read(@experiment.cache_key(name, suffix: :attrs)) end |
#attr_inc(name, amount = 1) ⇒ Object
37 38 39 |
# File 'lib/gitlab/experiment/cache.rb', line 37 def attr_inc(name, amount = 1) store.increment(@experiment.cache_key(name, suffix: :attrs), amount) end |
#attr_set(name, value) ⇒ Object
33 34 35 |
# File 'lib/gitlab/experiment/cache.rb', line 33 def attr_set(name, value) store.write(@experiment.cache_key(name, suffix: :attrs), value) end |
#delete ⇒ Object
25 26 27 |
# File 'lib/gitlab/experiment/cache.rb', line 25 def delete store.delete(key) end |
#read ⇒ Object
17 18 19 |
# File 'lib/gitlab/experiment/cache.rb', line 17 def read store.read(key) end |
#write(value = nil) ⇒ Object
21 22 23 |
# File 'lib/gitlab/experiment/cache.rb', line 21 def write(value = nil) store.write(key, value || @experiment.assigned.name) end |