Method: Redis::Commands::Hashes#hsetnx

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

#hsetnx(key, field, value) ⇒ Boolean

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

Parameters:

  • key (String)
  • field (String)
  • value (String)

Returns:

  • (Boolean)

    whether or not the field was added to the hash



35
36
37
# File 'lib/redis/commands/hashes.rb', line 35

def hsetnx(key, field, value)
  send_command([:hsetnx, key, field, value], &Boolify)
end