Class: VK::SORTEDSET
- Inherits:
-
O
show all
- Defined in:
- lib/valkey/objects.rb
Instance Attribute Summary
Attributes inherited from O
#key
Instance Method Summary
collapse
Methods inherited from O
#delete!, #expire, #initialize
Constructor Details
This class inherits a constructor from VK::O
Instance Method Details
#[](k) ⇒ Object
497
498
499
|
# File 'lib/valkey/objects.rb', line 497
def [] k
VK.redis.call("ZSCORE", key, k).to_f;
end
|
#[]=(k, v) ⇒ Object
500
501
502
|
# File 'lib/valkey/objects.rb', line 500
def []= k,v
VK.redis.call("ZADD", key, v, k).to_f;
end
|
#poke(k, n) ⇒ Object
503
504
505
|
# File 'lib/valkey/objects.rb', line 503
def poke k, n
VK.redis.call("ZINCRBY", key, n.to_f, k);
end
|
#to_h ⇒ Object
492
493
494
495
496
|
# File 'lib/valkey/objects.rb', line 492
def to_h
h = {}
VK.redis.call("ZREVRANGE", key, 0, -1, 'WITHSCORES').each_with_index { |e, i| h[e[0]] = e[1] }
return h
end
|
#value(&b) ⇒ Object
486
487
488
489
490
491
|
# File 'lib/valkey/objects.rb', line 486
def value &b
VK.redis.call("ZREVRANGE", key, 0, -1, 'WITHSCORES').each_with_index { |e, i| b.call(i, e) }
if @opts.has_key?(:flush) == true
delete!
end
end
|