forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StringCommands.java
321 lines (291 loc) · 10.2 KB
/
StringCommands.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
package io.quarkus.redis.datasource.string;
import java.util.Map;
import io.quarkus.redis.datasource.RedisCommands;
/**
* Allows executing commands from the {@code string} group.
* See <a href="https://redis.io/commands/?group=string">the string command list</a> for further information
* about these commands.
* <p>
* This group can be used with value of type {@code String}, or a type which will be automatically
* serialized/deserialized with a codec.
*
* @param <K> the type of the key
* @param <V> the type of the value
* @deprecated Use {@link io.quarkus.redis.datasource.value.ValueCommands} instead.
*/
@Deprecated
public interface StringCommands<K, V> extends RedisCommands {
/**
* Execute the command <a href="https://redis.io/commands/append">APPEND</a>.
* Summary: Append a value to a key
* Group: string
* Requires Redis 2.0.0
*
* @param key the key
* @param value the value
* @return the length of the string after the append operation.
**/
long append(K key, V value);
/**
* Execute the command <a href="https://redis.io/commands/decr">DECR</a>.
* Summary: Decrement the integer value of a key by one
* Group: string
* Requires Redis 1.0.0
*
* @param key the key
* @return the value of key after the decrement
**/
long decr(K key);
/**
* Execute the command <a href="https://redis.io/commands/decrby">DECRBY</a>.
* Summary: Decrement the integer value of a key by the given number
* Group: string
* Requires Redis 1.0.0
*
* @param key the key
* @param amount the amount, can be negative
* @return the value of key after the decrement
**/
long decrby(K key, long amount);
/**
* Execute the command <a href="https://redis.io/commands/get">GET</a>.
* Summary: Get the value of a key
* Group: string
* Requires Redis 1.0.0
*
* @param key the key
* @return the value of key, or {@code null} when key does not exist.
**/
V get(K key);
/**
* Execute the command <a href="https://redis.io/commands/getdel">GETDEL</a>.
* Summary: Get the value of a key and delete the key
* Group: string
* Requires Redis 6.2.0
*
* @param key the key
* @return the value of key, {@code null} when key does not exist, or an error if the key's value type isn't a string.
**/
V getdel(K key);
/**
* Execute the command <a href="https://redis.io/commands/getex">GETEX</a>.
* Summary: Get the value of a key and optionally set its expiration
* Group: string
* Requires Redis 6.2.0
*
* @param key the key
* @param args the getex command extra-arguments
* @return the value of key, or {@code null} when key does not exist.
**/
V getex(K key, GetExArgs args);
/**
* Execute the command <a href="https://redis.io/commands/getrange">GETRANGE</a>.
* Summary: Get a substring of the string stored at a key
* Group: string
* Requires Redis 2.4.0
*
* @param key the key
* @param start the start offset
* @param end the end offset
* @return the sub-string
**/
String getrange(K key, long start, long end);
/**
* Execute the command <a href="https://redis.io/commands/getset">GETSET</a>.
* Summary: Set the string value of a key and return its old value
* Group: string
* Requires Redis 1.0.0
*
* @param key the key
* @param value the value
* @return the old value stored at key, or {@code null} when key did not exist.
* @deprecated See https://redis.io/commands/getset
**/
V getset(K key, V value);
/**
* Execute the command <a href="https://redis.io/commands/incr">INCR</a>.
* Summary: Increment the integer value of a key by one
* Group: string
* Requires Redis 1.0.0
*
* @param key the key
* @return the value of key after the increment
**/
long incr(K key);
/**
* Execute the command <a href="https://redis.io/commands/incrby">INCRBY</a>.
* Summary: Increment the integer value of a key by the given amount
* Group: string
* Requires Redis 1.0.0
*
* @param key the key
* @param amount the amount, can be negative
* @return the value of key after the increment
**/
long incrby(K key, long amount);
/**
* Execute the command <a href="https://redis.io/commands/incrbyfloat">INCRBYFLOAT</a>.
* Summary: Increment the float value of a key by the given amount
* Group: string
* Requires Redis 2.6.0
*
* @param key the key
* @param amount the amount, can be negative
* @return the value of key after the increment.
**/
double incrbyfloat(K key, double amount);
/**
* Execute the command <a href="https://redis.io/commands/lcs">LCS</a>.
* Summary: Find longest common substring
* Group: string
* Requires Redis 7.0.0
*
* @param key1 the key
* @param key2 the key
* @return the string representing the longest common substring is returned.
**/
String lcs(K key1, K key2);
/**
* Execute the command <a href="https://redis.io/commands/lcs">LCS</a>.
* Summary: Find longest common substring and return the length (using {@code LEN})
* Group: string
* Requires Redis 7.0.0
*
* @param key1 the key
* @param key2 the key
* @return the length of the longest common substring.
**/
long lcsLength(K key1, K key2);
// TODO Add LCS with IDX support
/**
* Execute the command <a href="https://redis.io/commands/mget">MGET</a>.
* Summary: Get the values of all the given keys
* Group: string
* Requires Redis 1.0.0
*
* @param keys the keys
* @return list of values at the specified keys. If one of the passed key does not exist, the returned map contains
* a {@code null} value associated with the missing key.
**/
Map<K, V> mget(K... keys);
/**
* Execute the command <a href="https://redis.io/commands/mset">MSET</a>.
* Summary: Set multiple keys to multiple values
* Group: string
* Requires Redis 1.0.1
*
* @param map the key/value map containing the items to store
* @return a Uni producing a {@code null} item on success, a failure otherwise
**/
void mset(Map<K, V> map);
/**
* Execute the command <a href="https://redis.io/commands/msetnx">MSETNX</a>.
* Summary: Set multiple keys to multiple values, only if none of the keys exist
* Group: string
* Requires Redis 1.0.1
*
* @param map the key/value map containing the items to store
* @return {@code true} the all the keys were set. {@code false} no key was set (at least one key already existed).
**/
boolean msetnx(Map<K, V> map);
/**
* Execute the command <a href="https://redis.io/commands/psetex">PSETEX</a>.
* Summary: Set the value and expiration in milliseconds of a key
* Group: string
* Requires Redis 2.6.0
*
* @param key the key
* @param milliseconds the duration in ms
* @param value the value
* @return a Uni producing a {@code null} item on success, a failure otherwise
**/
void psetex(K key, long milliseconds, V value);
/**
* Execute the command <a href="https://redis.io/commands/set">SET</a>.
* Summary: Set the string value of a key
* Group: string
* Requires Redis 1.0.0
*
* @param key the key
* @param value the value
* @return a Uni producing a {@code null} item on success, a failure otherwise
**/
void set(K key, V value);
/**
* Execute the command <a href="https://redis.io/commands/set">SET</a>.
* Summary: Set the string value of a key
* Group: string
* Requires Redis 1.0.0
*
* @param key the key
* @param value the value
* @param setArgs the set command extra-arguments
* @return a Uni producing a {@code null} item on success, a failure otherwise
**/
void set(K key, V value, SetArgs setArgs);
/**
* Execute the command <a href="https://redis.io/commands/set">SET</a>.
* Summary: Set the string value of a key, and return the previous value
* Group: string
* Requires Redis 1.0.0
*
* @param key the key
* @param value the value
* @return the old value, {@code null} if not present
**/
V setGet(K key, V value);
/**
* Execute the command <a href="https://redis.io/commands/set">SET</a>.
* Summary: Set the string value of a key, and return the previous value
* Group: string
* Requires Redis 1.0.0
*
* @param key the key
* @param value the value
* @param setArgs the set command extra-arguments
* @return the old value, {@code null} if not present
**/
V setGet(K key, V value, SetArgs setArgs);
/**
* Execute the command <a href="https://redis.io/commands/setex">SETEX</a>.
* Summary: Set the value and expiration of a key
* Group: string
* Requires Redis 2.0.0
*
* @param key the key
* @param value the value
**/
void setex(K key, long seconds, V value);
/**
* Execute the command <a href="https://redis.io/commands/setnx">SETNX</a>.
* Summary: Set the value of a key, only if the key does not exist
* Group: string
* Requires Redis 1.0.0
*
* @param key the key
* @param value the value
* @return {@code true} the key was set {@code false} the key was not set
**/
boolean setnx(K key, V value);
/**
* Execute the command <a href="https://redis.io/commands/setrange">SETRANGE</a>.
* Summary: Overwrite part of a string at key starting at the specified offset
* Group: string
* Requires Redis 2.2.0
*
* @param key the key
* @param value the value
* @return the length of the string after it was modified by the command.
**/
long setrange(K key, long offset, V value);
/**
* Execute the command <a href="https://redis.io/commands/strlen">STRLEN</a>.
* Summary: Get the length of the value stored in a key
* Group: string
* Requires Redis 2.2.0
*
* @param key the key
* @return the length of the string at key, or 0 when key does not exist.
**/
long strlen(K key);
}