Method: Redis::Commands::Strings#getset

Defined in:
lib/redis/commands/strings.rb

#getset(key, value) ⇒ String

Set the string value of a key and return its old value.

Parameters:

  • key (String)
  • value (String)

    value to replace the current value with

Returns:

  • (String)

    the old value stored in the key, or nil if the key did not exist

[View source] [View on GitHub]

265
266
267
# File 'lib/redis/commands/strings.rb', line 265

def getset(key, value)
  send_command([:getset, key, value.to_s])
end