Class: VK::COUNTER

Inherits:
O
  • Object
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

#decr(n) ⇒ Object



431
432
433
# File 'lib/valkey/objects.rb', line 431

def decr n
  VK.redis.call("SET", @key, value - n.to_f)
end

#exist?Boolean

Returns:

  • (Boolean)


444
445
446
# File 'lib/valkey/objects.rb', line 444

def exist?                                                                                                                                        
  VK.redis.call("GET", @key) ? true : false                                                                                                        
end

#incr(n) ⇒ Object



428
429
430
# File 'lib/valkey/objects.rb', line 428

def incr n
  VK.redis.call("SET", @key, value + n.to_f)
end

#valueObject



434
435
436
437
438
439
440
# File 'lib/valkey/objects.rb', line 434

def value
  x = VK.redis.call("GET", @key).to_f
  if @opts.has_key?(:flush) == true                                                                                                               
    delete!                                                                                                                                       
  end
  return x
end

#value=(n) ⇒ Object



441
442
443
# File 'lib/valkey/objects.rb', line 441

def value= n
  VK.redis.call("SET", @key, n.to_f)
end