Add new redis command DELMPUB
[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 ## DELMPUB number_of_keys number_of_channel_message_pairs key [ key ... ] channel message [ channel message ... ]
163
164 Time complexity: O(N) where N is the number of keys that will be removed + 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)
165
166 Remove the specified keys. If any of the keys was deleted succesfully (delete return value > 0) then post given messages to the corresponding channels.
167
168 ## DELIEPUB 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 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 ## DELNEPUB key oldvalue channel message [channel message...]
175
176 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)
177
178 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.
179
180 ## NGET pattern
181
182 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
183
184 Returns all key-value pairs matching pattern.
185
186 ```
187 example:
188
189 redis> nget mykey*
190 (empty list or set)
191
192 redis> set mykey1 "myvalue1"
193 OK
194 redis> set mykey2 "myvalue2"
195 OK
196 redis> set mykey3 "myvalue3"
197 OK
198 redis> set mykey4 "myvalue4"
199 OK
200 redis> nget mykey*
201 1) "mykey2"
202 2) "myvalue2"
203 3) "mykey1"
204 4) "myvalue1"
205 5) "mykey4"
206 6) "myvalue4"
207 7) "mykey3"
208 8) "myvalue3"
209 ```
210
211 ## NDEL pattern
212
213 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
214
215 Remove all key-value pairs matching pattern.
216
217 ```
218 example:
219
220 redis> nget mykey*
221 1) "mykey2"
222 2) "myvalue2"
223 3) "mykey1"
224 4) "myvalue1"
225 5) "mykey4"
226 6) "myvalue4"
227 7) "mykey3"
228 8) "myvalue3"
229
230 redis> ndel mykey*
231 (integer) 4
232
233 redis> ndel mykey*
234 (integer) 0
235 ```