Class: Jylis::DataType::GCOUNT
- Defined in:
- lib/jylis-rb/data_types/gcount.rb
Overview
A grow-only counter.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#get(key) ⇒ Integer
Get the resulting ‘value` for the counter at `key`.
-
#inc(key, value) ⇒ Object
Increase the counter at ‘key` by the amount of `value`.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Jylis::DataType::Base
Instance Method Details
#get(key) ⇒ Integer
Get the resulting ‘value` for the counter at `key`.
10 11 12 |
# File 'lib/jylis-rb/data_types/gcount.rb', line 10 def get(key) connection.query("GCOUNT", "GET", key) end |
#inc(key, value) ⇒ Object
Increase the counter at ‘key` by the amount of `value`.
15 16 17 18 19 20 21 |
# File 'lib/jylis-rb/data_types/gcount.rb', line 15 def inc(key, value) result = connection.query("GCOUNT", "INC", key, value) unless result == "OK" raise "Failed: GCOUNT INC #{key} #{value}" end end |