sadd

// Using callbacks (NodeJS or Web Browser)
kuzzle.memoryStorage.sadd('key', ['foo', 'bar', 'baz'], function (err, count) {
  // callback called once the action has completed
});

// Using promises (NodeJS only)
kuzzle.memoryStorage.saddPromise('key', ['foo', 'bar', 'baz'])
  .then(count => {
    // resolved once the action has completed
  });
String[] items = new String[]{"foo", "bar", "baz"};

kuzzle.memoryStorage.sadd("key", items, new ResponseListener<Long>() {
  @Override
  public void onSuccess(int count) {
    // callback called once the action has completed
  }

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

use \Kuzzle\Kuzzle;


$kuzzle = new Kuzzle('localhost');

try {
  $count = $kuzzle->memoryStorage()->sadd('key', ['foo', 'bar', 'baz']);
}
catch (ErrorException $e) {

}

Callback response:

6

Adds members to a set of unique values stored at key. If the key does not exist, it is created beforehand.

[Redis documentation]


sadd(key, members, [options], [callback])

ArgumentsTypeDescription
keystringKey identifier
membersarrayMembers to add to the list of unique values
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 containing the number of added elements to the set.