HSETEX

Syntax

  1. HSETEX key seconds field value [field value ...]

Time complexity: O(1) for each field/value pair added, so O(N) to add N field/value pairs when the command is called with multiple field/value pairs.

ACL categories: @read, @hash, @fast

Warning: Experimental! Dragonfly specific.

Simimar to HSET but adds one or more hash fieds that expire after specified number of seconds. This command overwrites the values of specified fields that exist in the hash. If key doesn’t exist, a new key holding a hash is created. In any case, the ttl is updated according to the latest value and the current clock.

Return

Integer reply: The number of fields that were added.

Examples

  1. dragonfly> HSETEX myhash 5 field1 "Hello"
  2. (integer) 1
  3. # wait for 4 seconds
  4. dragonfly> HGETALL myhash
  5. 1) "field1"
  6. 2) "Hello"
  7. # wait for 1 seconds
  8. dragonfly> HGETALL myhash
  9. (empty array)