hsetnx

// Using callbacks (NodeJS or Web Browser)
kuzzle.memoryStorage.hsetnx('key', 'field', 'value', function (err, status) {
  // callback called once the action has completed
});

// Using promises (NodeJS only)
kuzzle.memoryStorage.hsetnxPromise('key', 'field', 'value')
  .then(status => {
    // resolved once the action has completed
  });
kuzzle.memoryStorage.hsetnx("key", "field", "value", new ResponseListener<Integer>() {
  @Override
  public void onSuccess(Integer status) {
    // callback called once the action has completed
  }

  @Override
  public void onError(JSONObject error) {
  }
});
<?php

use \Kuzzle\Kuzzle;


$kuzzle = new Kuzzle('localhost');

try {
  $status = $kuzzle->memoryStorage()->hsetnx('key', 'field', 'value');
}
catch (ErrorException $e) {

}

Callback response:

1

Sets a field and its value in a hash, only if the field does not already exist.

[Redis documentation]


hsetnx(key, field, value, [options], [callback])

ArgumentsTypeDescription
keystringKey identifier
fieldstringField name to insert or to update
valuestringAssociated field value
optionsJSON ObjectOptional parameters
callbackfunctionCallback

Options

OptionTypeDescriptionDefault
queuablebooleanMark this request as (not) queuabletrue

Return value

Returns the MemoryStorage object to allow chaining.


Callback response

Resolves to an integer indicating if the insertion succeeded (1) or failed (0).