HSETEX

Since 1.1.0Hashes

Syntax

HSETEX key [FNX | FXX] [EX seconds | PX milliseconds | EXAT unix-seconds | PXAT unix-milliseconds | KEEPTTL] FIELDS numfields field value [field value ...]
  • Flags: write
  • ACL categories: @hash, @slow, @write
  • Arity: -2

Sets fields of the hash at key, with one expiry for all of them, in one step.

Options

OptionEffect
FNXSet only if none of the fields exists.
FXXSet only if every field exists.
EX, PX, EXAT, PXATGive the fields this expiry.
KEEPTTLKeep each field's current expiry.

Without an expiry option, the fields end up with none.

KiviDB also accepts its older form, HSETEX key seconds [FNX | FXX] [KEEPTTL] FIELDS numfields field value ..., with the seconds first.

Reply

  • 1 if the fields were set.
  • 0 if FNX or FXX was not met; nothing is set.

Examples

> HSETEX hx EX 100 FIELDS 2 a 1 b 2
(integer) 1
> HTTL hx FIELDS 2 a b
1) (integer) 100
2) (integer) 100
> HSETEX hx FNX FIELDS 1 a 9
(integer) 0
> HSETEX hx FXX KEEPTTL FIELDS 1 a 10
(integer) 1
> HTTL hx FIELDS 1 a
1) (integer) 100