Skip to content

Commit 653b6ca

Browse files
authored
DEV: add new HFE commands (#1204)
1 parent 07d1b12 commit 653b6ca

File tree

8 files changed

+444
-0
lines changed

8 files changed

+444
-0
lines changed

content/commands/hgetdel/index.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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: numfields
13+
name: numfields
14+
type: integer
15+
- display_text: field
16+
multiple: true
17+
name: field
18+
type: string
19+
name: fields
20+
token: FIELDS
21+
type: block
22+
arity: -5
23+
categories:
24+
- docs
25+
- develop
26+
- stack
27+
- oss
28+
- rs
29+
- rc
30+
- oss
31+
- kubernetes
32+
- clients
33+
command_flags:
34+
- write
35+
- fast
36+
complexity: O(N) where N is the number of specified fields
37+
description: Returns the value of a field and deletes it from the hash.
38+
group: hash
39+
hidden: false
40+
key_specs:
41+
- RW: true
42+
access: true
43+
begin_search:
44+
spec:
45+
index: 1
46+
type: index
47+
delete: true
48+
find_keys:
49+
spec:
50+
keystep: 1
51+
lastkey: 0
52+
limit: 0
53+
type: range
54+
linkTitle: HGETDEL
55+
since: 8.0.0
56+
summary: Returns the value of a field and deletes it from the hash.
57+
syntax_fmt: "HGETDEL key FIELDS\_numfields field [field ...]"
58+
syntax_str: "FIELDS\_numfields field [field ...]"
59+
title: HGETDEL
60+
---
61+
Get and delete the value of one or more fields of a given hash key. When the last field is deleted, the key will also be deleted.
62+
63+
## Example
64+
65+
```
66+
redis> HSET mykey field1 "Hello" field2 "World" field3 "!"
67+
(integer) 3
68+
redis> HGETALL mykey
69+
1) "field1"
70+
2) "Hello"
71+
3) "field2"
72+
4) "World"
73+
5) "field3"
74+
6) "!"
75+
redis> HGETDEL mykey FIELDS 2 field3 field4
76+
1) "!"
77+
2) (nil)
78+
redis> HGETALL mykey
79+
1) "field1"
80+
2) "Hello"
81+
3) "field2"
82+
4) "World"
83+
redis> HGETDEL mykey FIELDS 2 field1 field2
84+
1) "Hello"
85+
2) "World"
86+
redis> KEYS *
87+
(empty array)
88+
```
Lines changed: 20 additions & 0 deletions
Loading

content/commands/hgetex/index.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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+
```

content/commands/hgetex/syntax.svg

Lines changed: 20 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)