a49c3da4c1318a707399b454d751768db8dceef8
[ric-plt/dbaas.git] / redismodule / README.md
1 # Introduction
2
3 This subdirectory provides implementation for the commands which are implemented
4 as a [Redis modules](https://redis.io/topics/modules-intro).
5
6 # Commands
7
8 ## SETIE key value oldvalue [expiration EX seconds|PX milliseconds]
9
10 Time complexity: O(1) + O(1)
11
12 Checks a String 'key' for 'oldvalue' equality and set key for 'value' with
13 optional expired.
14
15 ```
16 Example:
17
18 redis> get mykey
19 (nil)
20 redis> setie mykey "Hello again" "Hello"
21 (nil)
22
23 redis> set mykey "Hello"
24 OK
25 redis> get mykey
26 "Hello"
27 redis> setie mykey "Hello again" "Hello"
28 "OK"
29 redis> get mykey
30 "Hello again"
31 redis> setie mykey "Hello 2" "Hello"
32 (nil)
33 redis> get mykey
34 "Hello again"
35 redis> setie mykey "Hello 2" "Hello again" ex 100
36 "OK"
37 redis> ttl mykey
38 (integer) 96
39 redis> get mykey
40 "Hello 2"
41 ```
42
43 ## SETNE key value oldvalue [expiration EX seconds|PX milliseconds]
44
45 Time complexity: O(1) + O(1)
46
47 Checks a String 'key' for 'oldvalue' not equality and set key for 'value' with optional expired.
48
49 Example:
50
51 ```
52 redis> get mykey
53 (nil)
54 redis> setne mykey "Hello again" "Hello"
55 "OK"
56 redis> get mykey
57 "Hello again"
58 redis> setne mykey "Hello 2" "Hello again"
59 (nil)
60 redis> setne mykey "Hello 2" "Hello"
61 "OK"
62 redis> get mykey
63 "Hello 2"
64 redis> setne mykey "Hello 3" "Hello" ex 100
65 "OK"
66 redis> get mykey
67 "Hello 3"
68 redis> ttl mykey
69 (integer) 93
70 ```
71
72 ## DELIE key oldvalue
73
74 Time complexity: O(1) + O(1)
75
76 Checks a String 'key' for 'oldvalue' equality and delete the key.
77
78 ```
79 Example:
80 redis> get mykey
81 (nil)
82 redis> set mykey "Hello"
83 "OK"
84 redis> get mykey
85 "Hello"
86 redis> delie mykey "Hello again"
87 (integer) 0
88 redis> get mykey
89 "Hello"
90 redis> delie mykey "Hello"
91 (integer) 1
92 redis> get mykey
93 (nil)
94 ```
95
96 ## DELNE key oldvalue
97
98 Time complexity: O(1) + O(1)
99
100 Checks a String 'key' for 'oldvalue' not equality and delete the key.
101
102 ```
103 Example:
104 redis> get mykey
105 (nil)
106 redis> set mykey "Hello"
107 "OK"
108 redis> get mykey
109 "Hello"
110 redis> delne mykey "Hello"
111 (integer) 0
112 redis> get mykey
113 "Hello"
114 redis> delne mykey "Hello again"
115 (integer) 1
116 redis> get mykey
117 (nil)
118 ```
119
120 ## MSETPUB key value [key value...] channel message
121
122 Time complexity: O(N) where N is the number of keys to set + O(N+M) where N is the number of clients subscribed to the receiving channel and M is the total number of subscribed patterns (by any client)
123
124 Set the given keys to their respective values and post a message to the given channel
125
126 ## MSETMPUB number_of_key_value_pairs number_of_channel_message_pairs key value [ key value ... ] channel message [ channel message ... ]
127
128 Time complexity: O(N) where N is the number of keys to set + O(N_1+M) [ + O(N_2+M) + ... ] where N_i are the number of clients subscribed to the corresponding receiving channel and M is the total number of subscribed patterns (by any client)
129
130 Set the given keys to their respective values and post messages to their respective channels
131
132 ## SETXXPUB key value channel message [channel message...]
133
134 Time complexity: O(1) + O(1) + O(N_1+M) [ + O(N_2+M) + ... ] where N_i are the number of clients subscribed to the receiving channel and M is the total number of subscribed patterns (by any client).
135
136 Set key to hold string value if key already exists and post given messages to the corresponding channels if key value was set successfully
137
138 ## SETNXPUB key value channel message [channel message...]
139
140 Time complexity: O(1) + O(1) + O(N_1+M) [ + O(N_2+M) + ... ] where N_i are the number of clients subscribed to the receiving channel and M is the total number of subscribed patterns (by any client).
141
142 Set key to hold string value if key does not exist and post given messages to the corresponding channels if key value was set successfully
143
144 ## SETIEPUB key value oldvalue channel message [channel message...]
145
146 Time complexity: O(1) + O(1) + O(1) + O(N_1+M) [ + O(N_2+M) + ... ] where N_i are the number of clients subscribed to the receiving channel and M is the total number of subscribed patterns (by any client).
147
148 If the string corresponding to 'key' is equal to 'oldvalue' then set key for 'value' and post given messages to the corresponding channels if key value was set successfully
149
150 ## SETNEPUB key value oldvalue channel message [channel message...]
151
152 Time complexity: O(1) + O(1) + O(1) + O(N_1+M) [ + O(N_2+M) + ... ] where N_i are the number of clients subscribed to the receiving channel and M is the total number of subscribed patterns (by any client).
153
154 If the string corresponding to 'key' is not equal to 'oldvalue' then set key for 'value' and post given messages to the corresponding channels if key value was set successfully
155
156 ## DELPUB key [key...] channel message
157
158 Time complexity: O(N) where N is the number of keys that will be removed + O(N+M) where N is the number of clients subscribed to the receiving channel and M is the total number of subscribed patterns (by any client)
159
160 Removes the specified keys and post a message to the given channel if delete key successfully(return >0)
161
162 ## DELIEPUB key oldvalue channel message [channel message...]
163
164 Time complexity: O(1) + O(1) + O(1) + O(N_1+M) [ + O(N_2+M) + ...] where N_i are the number of clients subscribed to the corrensponding receiving channel and M is the total number of subscribed patterns (by any client)
165
166 If the string corresponding to 'key' is equal to 'oldvalue' then delete the key. If deletion was succesful (delete return value was 1) then post given messages to the corresponding channels.
167
168 ## DELNEPUB key oldvalue channel message [channel message...]
169
170 Time complexity: O(1) + O(1) + O(1) + O(N_1+M) [ + O(N_2+M) + ...] where N_i are the number of clients subscribed to the corrensponding receiving channel and M is the total number of subscribed patterns (by any client)
171
172 If the string corresponding to 'key' is not equal to 'oldvalue' then delete the key. If deletion was succesful (delete return value was 1) then post given messages to the corresponding channels.
173
174 ## NGET pattern
175
176 Time complexity: O(N) with N being the number of keys in the instance + O(N) where N is the number of keys to retrieve
177
178 Returns all key-value pairs matching pattern.
179
180 ```
181 example:
182
183 redis> nget mykey*
184 (empty list or set)
185
186 redis> set mykey1 "myvalue1"
187 OK
188 redis> set mykey2 "myvalue2"
189 OK
190 redis> set mykey3 "myvalue3"
191 OK
192 redis> set mykey4 "myvalue4"
193 OK
194 redis> nget mykey*
195 1) "mykey2"
196 2) "myvalue2"
197 3) "mykey1"
198 4) "myvalue1"
199 5) "mykey4"
200 6) "myvalue4"
201 7) "mykey3"
202 8) "myvalue3"
203 ```
204
205 ## NDEL pattern
206
207 Time complexity: O(N) with N being the number of keys in the instance + O(N) where N is the number of keys that will be removed
208
209 Remove all key-value pairs matching pattern.
210
211 ```
212 example:
213
214 redis> nget mykey*
215 1) "mykey2"
216 2) "myvalue2"
217 3) "mykey1"
218 4) "myvalue1"
219 5) "mykey4"
220 6) "myvalue4"
221 7) "mykey3"
222 8) "myvalue3"
223
224 redis> ndel mykey*
225 (integer) 4
226
227 redis> ndel mykey*
228 (integer) 0
229 ```