// Using callbacks (NodeJS or Web Browser)
kuzzle.memoryStorage.getset('key', 'new value', function (err, oldValue) {
  // callback called once the action has completed

// Using promises (NodeJS only)
kuzzle.memoryStorage.getsetPromise('key', 'new value')
  .then(oldValue => {
    // resolved once the action has completed
kuzzle.memoryStorage.getset("key", "new value", new ResponseListener<String>() {
  public void onSuccess(String oldValue) {
    // callback called once the action has completed

  public void onError(JSONObject error) {

use \Kuzzle\Kuzzle;

$kuzzle = new Kuzzle('localhost');

try {
  $oldValue = $kuzzle->memoryStorage()->getset('key', 'oldValue');
catch (ErrorException $e) {


Callback response:


Sets a new value for a key and returns its previous value.

[Redis documentation]

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

keystringKey identifier
valuestringKey's new value
optionsJSON ObjectOptional parameters


queuablebooleanMark this request as (not) queuabletrue

Return value

Returns the MemoryStorage object to allow chaining.

Callback response

Resolves to the key's previous value.