getset

// 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>() {
  @Override
  public void onSuccess(String oldValue) {
    // callback called once the action has completed
  }

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

use \Kuzzle\Kuzzle;


$kuzzle = new Kuzzle('localhost');

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

}

Callback response:

"value"

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

[Redis documentation]


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

ArgumentsTypeDescription
keystringKey identifier
valuestringKey's new 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 the key's previous value.