Method: Redis#setnx

Defined in:
lib/redis.rb

#setnx(key, value) ⇒ Boolean

Set the value of a key, only if the key does not exist.

Parameters:

  • key (String)
  • value (String)

Returns:

  • (Boolean)

    whether the key was set or not



1230
1231
1232
1233
1234
# File 'lib/redis.rb', line 1230

def setnx(key, value)
  synchronize do
    @client.call [:setnx, key, value], &_boolify
  end
end