Class: Jylis::DataType::TREG
- Defined in:
- lib/jylis-rb/data_types/treg.rb
Overview
A timestamped register.
Defined Under Namespace
Classes: Result
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#get(key) ⇒ Jylis::DataType::TREG::Result
Get the latest ‘value` and `timestamp` for the register at `key`.
-
#set(key, value, timestamp) ⇒ Object
Set a ‘value` and `timestamp` for the register at `key`.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Jylis::DataType::Base
Instance Method Details
#get(key) ⇒ Jylis::DataType::TREG::Result
Get the latest ‘value` and `timestamp` for the register at `key`.
51 52 53 54 55 |
# File 'lib/jylis-rb/data_types/treg.rb', line 51 def get(key) result = connection.query("TREG", "GET", key) Result.parse(result) end |
#set(key, value, timestamp) ⇒ Object
Set a ‘value` and `timestamp` for the register at `key`.
60 61 62 63 64 65 66 67 |
# File 'lib/jylis-rb/data_types/treg.rb', line 60 def set(key, value, ) = Time.parse().utc.to_i if .is_a?(String) result = connection.query("TREG", "SET", key, value, ) unless result == "OK" raise "Failed: TREG SET #{key} #{value} #{}" end end |