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

  public void onError(JSONObject error) {

use \Kuzzle\Kuzzle;

$kuzzle = new Kuzzle('localhost');

try {
  $status = $kuzzle->memoryStorage()->setex('key', 'value', 42);
catch (ErrorException $e) {


Callback response:


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])

keystringKey identifier
valuestringValue to set
ttlintTime to live of the key, in seconds
optionsJSON ObjectOptional parameters


queuablebooleanMark this request as (not) queuabletrue

Return value

Returns the MemoryStorage object to allow chaining.

Callback response

Resolves to a simple "OK" string.