|
| 1 | +--- |
| 2 | +acl_categories: |
| 3 | +- '@write' |
| 4 | +- '@hash' |
| 5 | +- '@fast' |
| 6 | +arguments: |
| 7 | +- display_text: key |
| 8 | + key_spec_index: 0 |
| 9 | + name: key |
| 10 | + type: key |
| 11 | +- arguments: |
| 12 | + - display_text: seconds |
| 13 | + name: seconds |
| 14 | + token: EX |
| 15 | + type: integer |
| 16 | + - display_text: milliseconds |
| 17 | + name: milliseconds |
| 18 | + token: PX |
| 19 | + type: integer |
| 20 | + - display_text: unix-time-seconds |
| 21 | + name: unix-time-seconds |
| 22 | + token: EXAT |
| 23 | + type: unix-time |
| 24 | + - display_text: unix-time-milliseconds |
| 25 | + name: unix-time-milliseconds |
| 26 | + token: PXAT |
| 27 | + type: unix-time |
| 28 | + - display_text: persist |
| 29 | + name: persist |
| 30 | + token: PERSIST |
| 31 | + type: pure-token |
| 32 | + name: expiration |
| 33 | + optional: true |
| 34 | + type: oneof |
| 35 | +- arguments: |
| 36 | + - display_text: numfields |
| 37 | + name: numfields |
| 38 | + type: integer |
| 39 | + - display_text: field |
| 40 | + multiple: true |
| 41 | + name: field |
| 42 | + type: string |
| 43 | + name: fields |
| 44 | + token: FIELDS |
| 45 | + type: block |
| 46 | +arity: -5 |
| 47 | +categories: |
| 48 | +- docs |
| 49 | +- develop |
| 50 | +- stack |
| 51 | +- oss |
| 52 | +- rs |
| 53 | +- rc |
| 54 | +- oss |
| 55 | +- kubernetes |
| 56 | +- clients |
| 57 | +command_flags: |
| 58 | +- write |
| 59 | +- fast |
| 60 | +complexity: O(N) where N is the number of specified fields |
| 61 | +description: Get the value of one or more fields of a given hash key, and optionally |
| 62 | + set their expiration. |
| 63 | +group: hash |
| 64 | +hidden: false |
| 65 | +key_specs: |
| 66 | +- RW: true |
| 67 | + access: true |
| 68 | + begin_search: |
| 69 | + spec: |
| 70 | + index: 1 |
| 71 | + type: index |
| 72 | + find_keys: |
| 73 | + spec: |
| 74 | + keystep: 1 |
| 75 | + lastkey: 0 |
| 76 | + limit: 0 |
| 77 | + type: range |
| 78 | + notes: RW and UPDATE because it changes the TTL |
| 79 | + update: true |
| 80 | +linkTitle: HGETEX |
| 81 | +since: 8.0.0 |
| 82 | +summary: Get the value of one or more fields of a given hash key, and optionally set |
| 83 | + their expiration. |
| 84 | +syntax_fmt: "HGETEX key [EX\_seconds | PX\_milliseconds | EXAT\_unix-time-seconds\ |
| 85 | + \ |\n PXAT\_unix-time-milliseconds | PERSIST] FIELDS\_numfields field\n [field\ |
| 86 | + \ ...]" |
| 87 | +syntax_str: "[EX\_seconds | PX\_milliseconds | EXAT\_unix-time-seconds | PXAT\_unix-time-milliseconds\ |
| 88 | + \ | PERSIST] FIELDS\_numfields field [field ...]" |
| 89 | +title: HGETEX |
| 90 | +--- |
| 91 | +Get the value of one or more fields of a given hash key and optionally set their expirations (time-to-live or TTL). |
| 92 | + |
| 93 | +## Options |
| 94 | + |
| 95 | +The `HGETEX` command supports a set of options: |
| 96 | + |
| 97 | +* `EX seconds` -- Set the specified expiration time, in seconds. |
| 98 | +* `PX milliseconds` -- Set the specified expiration time, in milliseconds. |
| 99 | +* `EXAT unix-time-seconds` -- Set the specified Unix time at which the field will expire, in seconds. |
| 100 | +* `PXAT unix-time-milliseconds` -- Set the specified Unix time at which the field will expire, in milliseconds. |
| 101 | +* `PERSIST` -- Remove the TTL associated with the field. |
| 102 | + |
| 103 | +The `EX`, `PX`, `EXAT`, `PXAT`, and `PERSIST` options are mutually exclusive. |
| 104 | + |
| 105 | +## Example |
| 106 | + |
| 107 | +``` |
| 108 | +redis> HSET mykey field1 "Hello" field2 "World" |
| 109 | +(integer) 2 |
| 110 | +redis> HGETEX mykey EX 120 FIELDS 1 field1 |
| 111 | +1) "Hello" |
| 112 | +redis> HGETEX mykey EX 100 FIELDS 1 field2 |
| 113 | +1) "World" |
| 114 | +redis> HTTL mykey FIELDS 2 field1 field2 |
| 115 | +1) (integer) 91 |
| 116 | +2) (integer) 85 |
| 117 | +redis> HTTL mykey FIELDS 3 field1 field2 field3 |
| 118 | +1) (integer) 75 |
| 119 | +2) (integer) 68 |
| 120 | +3) (integer) -2 |
| 121 | +... |
| 122 | +redis> HTTL mykey FIELDS 3 field1 field2 |
| 123 | +1) (integer) -2 |
| 124 | +2) (integer) -2 |
| 125 | +redis> HGETALL mykey |
| 126 | +(empty array) |
| 127 | +``` |
0 commit comments