lib/redis/commands/strings.rb in redis-5.0.0.beta4 vs lib/redis/commands/strings.rb in redis-5.0.0
- old
+ new
@@ -23,11 +23,11 @@
#
# @param [String] key
# @param [Integer] decrement
# @return [Integer] value after decrementing it
def decrby(key, decrement)
- send_command([:decrby, key, decrement])
+ send_command([:decrby, key, Integer(decrement)])
end
# Increment the integer value of a key by one.
#
# @example
@@ -48,11 +48,11 @@
#
# @param [String] key
# @param [Integer] increment
# @return [Integer] value after incrementing it
def incrby(key, increment)
- send_command([:incrby, key, increment])
+ send_command([:incrby, key, Integer(increment)])
end
# Increment the numeric value of a key by the given float number.
#
# @example
@@ -61,11 +61,11 @@
#
# @param [String] key
# @param [Float] increment
# @return [Float] value after incrementing it
def incrbyfloat(key, increment)
- send_command([:incrbyfloat, key, increment], &Floatify)
+ send_command([:incrbyfloat, key, Float(increment)], &Floatify)
end
# Set the string value of a key.
#
# @param [String] key
@@ -80,14 +80,14 @@
# - `:keepttl => true`: Retain the time to live associated with the key.
# - `:get => true`: Return the old string stored at key, or nil if key did not exist.
# @return [String, Boolean] `"OK"` or true, false if `:nx => true` or `:xx => true`
def set(key, value, ex: nil, px: nil, exat: nil, pxat: nil, nx: nil, xx: nil, keepttl: nil, get: nil)
args = [:set, key, value.to_s]
- args << "EX" << ex if ex
- args << "PX" << px if px
- args << "EXAT" << exat if exat
- args << "PXAT" << pxat if pxat
+ args << "EX" << Integer(ex) if ex
+ args << "PX" << Integer(px) if px
+ args << "EXAT" << Integer(exat) if exat
+ args << "PXAT" << Integer(pxat) if pxat
args << "NX" if nx
args << "XX" if xx
args << "KEEPTTL" if keepttl
args << "GET" if get
@@ -231,22 +231,22 @@
# @param [String] key
# @param [Integer] offset byte offset
# @param [String] value
# @return [Integer] length of the string after it was modified
def setrange(key, offset, value)
- send_command([:setrange, key, offset, value.to_s])
+ send_command([:setrange, key, Integer(offset), value.to_s])
end
# Get a substring of the string stored at a key.
#
# @param [String] key
# @param [Integer] start zero-based start offset
# @param [Integer] stop zero-based end offset. Use -1 for representing
# the end of the string
# @return [Integer] `0` or `1`
def getrange(key, start, stop)
- send_command([:getrange, key, start, stop])
+ send_command([:getrange, key, Integer(start), Integer(stop)])
end
# Append a value to a key.
#
# @param [String] key
@@ -290,13 +290,13 @@
# expire, in milliseconds.
# - `:persist => true`: Remove the time to live associated with the key.
# @return [String] The value of key, or nil when key does not exist.
def getex(key, ex: nil, px: nil, exat: nil, pxat: nil, persist: false)
args = [:getex, key]
- args << "EX" << ex if ex
- args << "PX" << px if px
- args << "EXAT" << exat if exat
- args << "PXAT" << pxat if pxat
+ args << "EX" << Integer(ex) if ex
+ args << "PX" << Integer(px) if px
+ args << "EXAT" << Integer(exat) if exat
+ args << "PXAT" << Integer(pxat) if pxat
args << "PERSIST" if persist
send_command(args)
end