Class: VK::O
- Inherits:
-
Object
- Object
- VK::O
- Defined in:
- lib/valkey/objects.rb
Direct Known Subclasses
BOOK, CORPUS, COUNTER, HASH, HASHLIST, PLACE, QUEUE, SET, SORTEDHASH, SORTEDSET, TIMESTAMP, TOGGLE, VALUE, VECTOR
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #delete! ⇒ Object
- #expire(sec) ⇒ Object
-
#initialize(k, h = {}) ⇒ O
constructor
A new instance of O.
- #value ⇒ Object
Constructor Details
#initialize(k, h = {}) ⇒ O
Returns a new instance of O.
291 292 293 294 295 296 297 298 |
# File 'lib/valkey/objects.rb', line 291 def initialize k, h={} @key = k @opts = h # puts %[VK #{@key} #{h}] if @opts.has_key?(:ttl) expire @opts[:ttl] end end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
290 291 292 |
# File 'lib/valkey/objects.rb', line 290 def key @key end |
Instance Method Details
#delete! ⇒ Object
299 300 301 |
# File 'lib/valkey/objects.rb', line 299 def delete! VK.redis.call("DEL", key); end |
#expire(sec) ⇒ Object
302 303 304 |
# File 'lib/valkey/objects.rb', line 302 def expire sec VK.redis.call("EXPIRE", key, sec); end |
#value ⇒ Object
305 306 307 308 309 310 311 |
# File 'lib/valkey/objects.rb', line 305 def value x = VK.redis.call("GET", key); if @opts.has_key?(:flush) == true delete! end return x end |