set

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

// Using promises (NodeJS only)
kuzzle.memoryStorage.setPromise('key', 'value')
  .then(status => {
    // resolved once the action has completed
  });
kuzzle.memoryStorage.set("key", "value", new ResponseListener<String>() {
  @Override
  public void onSuccess(String 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()->set('key', 'value');
}
catch (ErrorException $e) {

}

Callback response:

"OK"

Creates a key holding the provided value, or overwrites it if it already exists.

[Redis documentation]


set(key, value, [options], [callback])

ArgumentsTypeDescription
keystringKey identifier
valuestringValue to store
optionsJSON ObjectOptional parameters
callbackfunctionCallback

Options

OptionTypeDescriptionDefault
exintTime to live of the key, in seconds0
nxbooleanSet the key only if it does not already existfalse
pxintTime to live of the key, in milliseconds0
queuablebooleanMark this request as (not) queuabletrue
xxbooleanSet the key only if it already existsfalse

Return value

Returns the MemoryStorage object to allow chaining.


Callback response

Resolves to a simple "OK" string.