Class: VK::SORTEDHASH
Instance Attribute Summary
Attributes inherited from O
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
606 607 608 609 |
# File 'lib/valkey/objects.rb', line 606 def [] k kx = %[#{@key}-#{k}] VK.redis.call("GET", kx) end |
#[]=(k, v) ⇒ Object
610 611 612 613 614 |
# File 'lib/valkey/objects.rb', line 610 def []= k, v kx = %[#{@key}-#{k}] VK.redis.call("SET", kx, v) VK.redis.call("ZINCRBY", key, 1, k) end |
#value(&b) ⇒ Object
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
# File 'lib/valkey/objects.rb', line 588 def value &b VK.redis.call("ZREVRANGE", key, 0, -1, 'WITHSCORES').each_with_index { |e, i| kx = %[#{@key}-#{e[0]}] a = [] if block_given? b.call(i, { key: e[0], value: VK.redis.call("GET", kx), score: e[1] } ) else a << { key: e[0], value: VK.redis.call("GET", kx), score: e[1] } end if @opts.has_key?(:flush) == true VK.redis.call("DEL", kx) end } if @opts.has_key?(:flush) == true delete! end return a end |