Skip to content

Commit 6b32e08

Browse files
committed
DOC-5718: add new string commands
1 parent 97d8999 commit 6b32e08

File tree

3 files changed

+69
-34
lines changed

3 files changed

+69
-34
lines changed

content/commands/delex.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,15 @@ Conditionally removes the specified key based on value or digest comparison.
7474

7575
## Options
7676

77-
The DELEX command supports a set of options that modify its behavior:
77+
The DELEX command supports a set of options that modify its behavior.
78+
Only one of the options can be specified.
7879

79-
* `IFEQ value` -- Remove the key if the value is equal to the specified value.
80-
* `IFNE value` -- Remove the key if the value is not equal to the specified value.
81-
* `IFDEQ digest` -- Remove the key if the digest is equal to the specified digest.
82-
* `IFDNE digest` -- Remove the key if the digest is not equal to the specified digest.
80+
* `IFEQ ifeq-value` -- Remove the key if the value is equal to the specified value.
81+
* `IFNE ifne-value` -- Remove the key if the value is not equal to the specified value.
82+
* `IFDEQ ifeq-digest` -- Remove the key if the digest is equal to the specified digest.
83+
* `IFDNE ifne-digest` -- Remove the key if the digest is not equal to the specified digest.
8384

84-
In 8.4, keys must be of type string.
85+
In 8.4, keys must be of type string when using one of the options above. If no options are specified, the key is removed regardless of its type.
8586

8687
## Return information
8788

@@ -90,12 +91,13 @@ In 8.4, keys must be of type string.
9091
tab2="RESP3" >}}
9192

9293
One of the following:
93-
- [Error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) if key exists but holds a value that is not a string and `IFEQ/IFNE/IFDEQ/IFDNE` is specified.
9494
- [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): 0 if not deleted (the key does not exist or a specified `IFEQ/IFNE/IFDEQ/IFDNE` condition is false), or 1 if deleted.
95+
- [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) if the key exists but holds a value that is not a string and one of `IFEQ, IFNE, IFDEQ,` or `IFDNE` is specified.
9596

9697
-tab-sep-
9798

98-
TODO: Add RESP3 return information
99+
One of the following:
100+
- [Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): 0 if not deleted (the key does not exist or a specified `IFEQ/IFNE/IFDEQ/IFDNE` condition is false), or 1 if deleted.
101+
- [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) if the key exists but holds a value that is not a string and one of `IFEQ, IFNE, IFDEQ,` or `IFDNE` is specified.
99102

100103
{{< /multitabs >}}
101-

content/commands/digest.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,32 @@ key_specs:
4141
type: range
4242
linkTitle: DIGEST
4343
since: 8.4.0
44-
summary: Returns the XXH3 hash of a string value.
44+
summary: Returns the XXH3 hash of a string value as a hexadecimal string.
4545
syntax_fmt: DIGEST key
4646
syntax_str: ''
4747
title: DIGEST
4848
---
49-
Returns the XXH3 hash of a string value.
5049

51-
## Required arguments
52-
53-
<details open><summary><code>key</code></summary>
54-
55-
TODO: Add description for key (key)
56-
57-
</details>
50+
Get the XXH3 hash digest for the value stored in the specified key as a hexadecimal string. Keys must be of type string.
5851

5952
## Return information
6053

6154
{{< multitabs id="return-info"
6255
tab1="RESP2"
6356
tab2="RESP3" >}}
6457

65-
TODO: Add RESP2 return information
58+
One of the following:
59+
60+
- [Null bulk string reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) if the key does not exist.
61+
- [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) if the key exists but holds a value which is not a string.
62+
- [Bulk string reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) the XXH3 digest of the value stored in the key as a hexadecimal string.
6663

6764
-tab-sep-
6865

69-
TODO: Add RESP3 return information
66+
One of the following:
7067

71-
{{< /multitabs >}}
68+
- [Null bulk string reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) if the key does not exist.
69+
- [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) if the key exists but holds a value which is not a string.
70+
- [Bulk string reply]({{< relref "/develop/reference/protocol-spec#bulk-strings" >}}) the XXH3 digest of the value stored in the key as a hexadecimal string.
7271

72+
{{< /multitabs >}}

content/commands/set.md

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ arguments:
2020
name: xx
2121
token: XX
2222
type: pure-token
23+
- display_text: ifeq-value
24+
name: ifeq-value
25+
since: 8.4.0
26+
token: IFEQ
27+
type: string
28+
- display_text: ifne-value
29+
name: ifne-value
30+
since: 8.4.0
31+
token: IFNE
32+
type: string
33+
- display_text: ifdeq-digest
34+
name: ifdeq-digest
35+
since: 8.4.0
36+
token: IFDEQ
37+
type: integer
38+
- display_text: ifdne-digest
39+
name: ifdne-digest
40+
since: 8.4.0
41+
token: IFDNE
42+
type: integer
2343
name: condition
2444
optional: true
2545
since: 2.6.12
@@ -87,6 +107,8 @@ history:
87107
- Added the `GET`, `EXAT` and `PXAT` option.
88108
- - 7.0.0
89109
- Allowed the `NX` and `GET` options to be used together.
110+
- - 8.4.0
111+
- Added 'IFEQ', 'IFNE', 'IFDEQ', 'IFDNE' options.
90112
key_specs:
91113
- RW: true
92114
access: true
@@ -107,12 +129,15 @@ linkTitle: SET
107129
since: 1.0.0
108130
summary: Sets the string value of a key, ignoring its type. The key is created if
109131
it doesn't exist.
110-
syntax_fmt: "SET key value [NX | XX] [GET] [EX\_seconds | PX\_milliseconds |\n EXAT\_\
111-
unix-time-seconds | PXAT\_unix-time-milliseconds | KEEPTTL]"
112-
syntax_str: "value [NX | XX] [GET] [EX\_seconds | PX\_milliseconds | EXAT\_unix-time-seconds\
132+
syntax_fmt: "SET key value [NX | XX | IFEQ\_ifeq-value | IFNE\_ifne-value |\n\
133+
\ IFDEQ\_ifdeq-digest | IFDNE\_ifdne-digest] [GET] [EX\_seconds |\n PX\_milliseconds\
134+
\ | EXAT\_unix-time-seconds |\n PXAT\_unix-time-milliseconds | KEEPTTL]"
135+
syntax_str: "value [NX | XX | IFEQ\_ifeq-value | IFNE\_ifne-value | IFDEQ\_ifdeq-digest\
136+
\ | IFDNE\_ifdne-digest] [GET] [EX\_seconds | PX\_milliseconds | EXAT\_unix-time-seconds\
113137
\ | PXAT\_unix-time-milliseconds | KEEPTTL]"
114138
title: SET
115139
---
140+
116141
Set `key` to hold the string `value`.
117142
If `key` already holds a value, it is overwritten, regardless of its type.
118143
Any previous time to live associated with the key is discarded on successful `SET` operation.
@@ -127,6 +152,10 @@ The `SET` command supports a set of options that modify its behavior:
127152
* `PXAT` *timestamp-milliseconds* -- Set the specified Unix time at which the key will expire, in milliseconds (a positive integer).
128153
* `NX` -- Only set the key if it does not already exist.
129154
* `XX` -- Only set the key if it already exists.
155+
* `IFEQ ifeq-value` -- Set the key’s value and expiration only if its current value is equal to `ifeq-value`. If the key doesn’t exist, it won’t be created.
156+
* `IFNE ifne-value` -- Set the key’s value and expiration only if its current value is not equal to `ifne-value`. If the key doesn’t exist, it will be created.
157+
* `IFDEQ ifeq-digest` -- Set the key’s value and expiration only if the digest of its current value is equal to `ifeq-digest`. If the key doesn’t exist, it won’t be created.
158+
* `IFDNE ifne-digest` -- Set the key’s value and expiration only if the digest of its current value is not equal to `ifne-digest`. If the key doesn’t exist, it will be created.
130159
* `KEEPTTL` -- Retain the time to live associated with the key.
131160
* `GET` -- Return the old string stored at key, or nil if key did not exist. An error is returned and `SET` aborted if the value stored at key is not a string.
132161

@@ -180,20 +209,24 @@ The script should be called with `EVAL ...script... 1 resource-name token-value`
180209
tab1="RESP2"
181210
tab2="RESP3" >}}
182211

183-
* If `GET` was not specified, any of the following:
184-
* [Nil reply](../../develop/reference/protocol-spec#bulk-strings): Operation was aborted (conflict with one of the `XX`/`NX` options). The key was not set.
212+
* If `GET` was not specified, one of the following:
213+
* [Null bulk string reply](../../develop/reference/protocol-spec#bulk-strings) in the following two cases.
214+
* The key doesn’t exist and `XX/IFEQ/IFDEQ` was specified. The key was not created.
215+
* The key exists, and `NX` was specified or a specified `IFEQ/IFNE/IFDEQ/IFDNE` condition is false. The key was not set.
185216
* [Simple string reply](../../develop/reference/protocol-spec#simple-strings): `OK`: The key was set.
186-
* If `GET` was specified, any of the following:
187-
* [Nil reply](../../develop/reference/protocol-spec#bulk-strings): The key didn't exist before the `SET`. If `XX` was specified, the key was not set. Otherwise, the key was set.
188-
* [Bulk string reply](../../develop/reference/protocol-spec#bulk-strings): The previous value of the key. If `NX` was specified, the key was not set. Otherwise, the key was set.
217+
* If `GET` was specified, one of the following:
218+
* [Null bulk string reply](../../develop/reference/protocol-spec#bulk-strings): The key didn't exist before the `SET` operation, whether the key was created of not.
219+
* [Bulk string reply](../../develop/reference/protocol-spec#bulk-strings): The previous value of the key, whether the key was set or not.
189220

190221
-tab-sep-
191222

192-
* If `GET` was not specified, any of the following:
193-
* [Null reply](../../develop/reference/protocol-spec#nulls): Operation was aborted (conflict with one of the `XX`/`NX` options). The key was not set.
223+
* If `GET` was not specified, one of the following:
224+
* [Null reply](../../develop/reference/protocol-spec#nulls) in the following two cases.
225+
* The key doesn’t exist and `XX/IFEQ/IFDEQ` was specified. The key was not created.
226+
* The key exists, and `NX` was specified or a specified `IFEQ/IFNE/IFDEQ/IFDNE` condition is false. The key was not set.
194227
* [Simple string reply](../../develop/reference/protocol-spec#simple-strings): `OK`: The key was set.
195-
* If `GET` was specified, any of the following:
196-
* [Null reply](../../develop/reference/protocol-spec#nulls): The key didn't exist before the `SET`. If `XX` was specified, the key was not set. Otherwise, the key was set.
197-
* [Bulk string reply](../../develop/reference/protocol-spec#bulk-strings): The previous value of the key. If `NX` was specified, the key was not set. Otherwise, the key was set.
228+
* If `GET` was specified, one of the following:
229+
* [Null reply](../../develop/reference/protocol-spec#nulls): The key didn't exist before the `SET` operation, whether the key was created of not.
230+
* [Bulk string reply](../../develop/reference/protocol-spec#bulk-strings): The previous value of the key, whether the key was set or not.
198231

199232
{{< /multitabs >}}

0 commit comments

Comments
 (0)