var elements = [
  {'score': 1, 'member': 'foo'},
  {'score': 2, 'member': 'bar'},
  {'score': 3, 'member': 'baz'}

// Using callbacks (NodeJS or Web Browser)
kuzzle.memoryStorage.zadd('key', elements, function (err, count) {
  // callback called once the action has completed

// Using promises (NodeJS only)
kuzzle.memoryStorage.zaddPromise('key', elements)
  .then(count => {
    // resolved once the action has completed
JSONObject[] elements = new JSONObject[]{
  new JSONObject().put("score", 1).put("member", "foo"),
  new JSONObject().put("score", 2).put("member", "bar"),
  new JSONObject().put("score", 3).put("member", "baz")

kuzzle.memoryStorage.zadd("key", elements new ResponseListener<Long>() {
  public void onSuccess(int count) {
    // callback called once the action has completed

  public void onError(JSONObject error) {

use \Kuzzle\Kuzzle;

$kuzzle = new Kuzzle('localhost');

$elements = [
  ['score' => 1, 'member' => 'foo'],
  ['score' => 2, 'member' => 'bar'],
  ['score' => 3, 'member' => 'baz']

try {
  $value = $kuzzle->memoryStorage()->zadd('key', elements);
catch (ErrorException $e) {


Callback response:


Adds the specified elements to the sorted set stored at key. If the key does not exist, it is created, holding an empty sorted set. If it already exists and does not hold a sorted set, an error is returned.

Scores are expressed as floating point numbers.

If a member to insert is already in the sorted set, its score is updated and the member is reinserted at the right position in the set.

[Redis documentation]

zadd(key, elements, [options], [callback])

keystringKey identifier
elementsarrayList of JSON objects detailing the element to add to the sorted set.
Properties: score (element's score, double), member (element's value, string)
optionsJSON ObjectOptional parameters


chbooleanInstead of returning the number of added allements, return the total number of changes performed (including updates)false
incrbooleanInstead of adding elements, increment the existing member with the provided score value. Only one score+element pair can be specified if this option is setfalse
nxbooleanOnly add new elements, do not update existing onesfalse
queuablebooleanMark this request as (not) queuabletrue
xxbooleanNever add new elements, update only exiting onesfalse

Return value

Returns the MemoryStorage object to allow chaining.

Callback response

Resolves to an integer containing the number of elements added to the sorted set.