setex

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

// Using promises (NodeJS only)
kuzzle.memoryStorage.setexPromise('key', 'value', 42)
  .then(status => {
    // resolved once the action has completed
  });
kuzzle.memoryStorage.setex("key", "value", 42, 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()->setex('key', 'value', 42);
}
catch (ErrorException $e) {

}

Callback response:

"OK"

Sets a key with the provided value, and an expiration delay expressed in seconds. If the key does not exist, it is created beforehand.

[Redis documentation]


setex(key, value, ttl, [options], [callback])

ArgumentsTypeDescription
keystringKey identifier
valuestringValue to set
ttlintTime to live of the key, in seconds
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 a simple "OK" string.