Class: Jylis::DataType::PNCOUNT
- Defined in:
- lib/jylis-rb/data_types/pncount.rb
Overview
A positive/negative counter.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#dec(key, value) ⇒ Object
Decrease the counter at ‘key` by the amount of `value`.
-
#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
#dec(key, value) ⇒ Object
Decrease the counter at ‘key` by the amount of `value`.
24 25 26 27 28 29 30 |
# File 'lib/jylis-rb/data_types/pncount.rb', line 24 def dec(key, value) result = connection.query("PNCOUNT", "DEC", key, value) unless result == "OK" raise "Failed: PNCOUNT DEC #{key} #{value}" end end |
#get(key) ⇒ Integer
Get the resulting ‘value` for the counter at `key`.
10 11 12 |
# File 'lib/jylis-rb/data_types/pncount.rb', line 10 def get(key) connection.query("PNCOUNT", "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/pncount.rb', line 15 def inc(key, value) result = connection.query("PNCOUNT", "INC", key, value) unless result == "OK" raise "Failed: PNCOUNT INC #{key} #{value}" end end |