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

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


Callback response:


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

[Redis documentation]

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

keystringKey identifier
valuestringValue to set
ttlintTime to live of the key, in milliseconds
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.