1 /*
2  * Hunt - A redis client library for D programming language.
3  *
4  * Copyright (C) 2018-2019 HuntLabs
5  *
6  * Website: https://www.huntlabs.net/
7  *
8  * Licensed under the Apache-2.0 License.
9  *
10  */
11  
12 module hunt.redis.commands.Commands;
13 
14 
15 import hunt.collection.Map;
16 import hunt.Double;
17 
18 import hunt.redis.BitOP;
19 import hunt.redis.StreamEntryID;
20 import hunt.redis.ListPosition;
21 import hunt.redis.ScanParams;
22 import hunt.redis.SortingParams;
23 import hunt.redis.ZParams;
24 import hunt.redis.params.MigrateParams;
25 import hunt.redis.params.ClientKillParams;
26 import hunt.redis.params.SetParams;
27 import hunt.redis.params.ZAddParams;
28 import hunt.redis.params.ZIncrByParams;
29 
30 interface Commands {
31 
32   void ping(string message);
33   
34   void set(string key, string value);
35 
36   void set(string key, string value, SetParams params);
37 
38   void get(string key);
39 
40   void exists(string[] keys...);
41 
42   void del(string[] keys...);
43 
44   void unlink(string[] keys...);
45 
46   void type(string key);
47 
48   void keys(string pattern);
49 
50   void rename(string oldkey, string newkey);
51 
52   void renamenx(string oldkey, string newkey);
53 
54   void expire(string key, int seconds);
55 
56   void expireAt(string key, long unixTime);
57 
58   void ttl(string key);
59 
60   void pttl(string key);
61 
62   void touch(string[] keys...);
63 
64   void setbit(string key, long offset, bool value);
65 
66   void setbit(string key, long offset, string value);
67 
68   void getbit(string key, long offset);
69 
70   void setrange(string key, long offset, string value);
71 
72   void getrange(string key, long startOffset, long endOffset);
73 
74   void move(string key, int dbIndex);
75 
76   void getSet(string key, string value);
77 
78   void mget(string[] keys...);
79 
80   void setnx(string key, string value);
81 
82   void setex(string key, int seconds, string value);
83 
84   void mset(string[] keysvalues...);
85 
86   void msetnx(string[] keysvalues...);
87 
88   void decrBy(string key, long decrement);
89 
90   void decr(string key);
91 
92   void incrBy(string key, long increment);
93 
94   void incrByFloat(string key, double increment);
95 
96   void incr(string key);
97 
98   void append(string key, string value);
99 
100   void substr(string key, int start, int end);
101 
102   void hset(string key, string field, string value);
103 
104   void hget(string key, string field);
105 
106   void hset(string key, Map!(string, string) hash);
107 
108   void hsetnx(string key, string field, string value);
109 
110   void hmset(string key, Map!(string, string) hash);
111 
112   void hmget(string key, string[] fields...);
113 
114   void hincrBy(string key, string field, long value);
115 
116   void hincrByFloat(string key, string field, double value);
117 
118   void hexists(string key, string field);
119 
120   void hdel(string key, string[] fields...);
121 
122   void hlen(string key);
123 
124   void hkeys(string key);
125 
126   void hvals(string key);
127 
128   void hgetAll(string key);
129 
130   void rpush(string key, string[] strings...);
131 
132   void lpush(string key, string[] strings...);
133 
134   void llen(string key);
135 
136   void lrange(string key, long start, long stop);
137 
138   void ltrim(string key, long start, long stop);
139 
140   void lindex(string key, long index);
141 
142   void lset(string key, long index, string value);
143 
144   void lrem(string key, long count, string value);
145 
146   void lpop(string key);
147 
148   void rpop(string key);
149 
150   void rpoplpush(string srckey, string dstkey);
151 
152   void sadd(string key, string[] members...);
153 
154   void smembers(string key);
155 
156   void srem(string key, string[] member...);
157 
158   void spop(string key);
159 
160   void spop(string key, long count);
161 
162   void smove(string srckey, string dstkey, string member);
163 
164   void scard(string key);
165 
166   void sismember(string key, string member);
167 
168   void sinter(string[] keys...);
169 
170   void sinterstore(string dstkey, string[] keys...);
171 
172   void sunion(string[] keys...);
173 
174   void sunionstore(string dstkey, string[] keys...);
175 
176   void sdiff(string[] keys...);
177 
178   void sdiffstore(string dstkey, string[] keys...);
179 
180   void srandmember(string key);
181 
182   void zadd(string key, double score, string member);
183 
184   void zadd(string key, double score, string member, ZAddParams params);
185 
186   void zadd(string key, Map!(string, double) scoreMembers);
187 
188   void zadd(string key, Map!(string, double) scoreMembers, ZAddParams params);
189 
190   void zrange(string key, long start, long stop);
191 
192   void zrem(string key, string[] members...);
193 
194   void zincrby(string key, double increment, string member);
195 
196   void zincrby(string key, double increment, string member, ZIncrByParams params);
197 
198   void zrank(string key, string member);
199 
200   void zrevrank(string key, string member);
201 
202   void zrevrange(string key, long start, long stop);
203 
204   void zrangeWithScores(string key, long start, long stop);
205 
206   void zrevrangeWithScores(string key, long start, long stop);
207 
208   void zcard(string key);
209 
210   void zscore(string key, string member);
211 
212   void watch(string[] keys...);
213 
214   void sort(string key);
215 
216   void sort(string key, SortingParams sortingParameters);
217 
218   void blpop(string[] args);
219 
220   void sort(string key, SortingParams sortingParameters, string dstkey);
221 
222   void sort(string key, string dstkey);
223 
224   void brpop(string[] args);
225 
226   void brpoplpush(string source, string destination, int timeout);
227 
228   void zcount(string key, double min, double max);
229 
230   void zcount(string key, string min, string max);
231 
232   void zrangeByScore(string key, double min, double max);
233 
234   void zrangeByScore(string key, string min, string max);
235 
236   void zrangeByScore(string key, double min, double max, int offset,
237       int count);
238 
239   void zrangeByScore(string key, string min, string max, int offset, int count);
240 
241   void zrangeByScoreWithScores(string key, double min, double max);
242 
243   void zrangeByScoreWithScores(string key, double min, double max,
244       int offset, int count);
245 
246   void zrangeByScoreWithScores(string key, string min, string max);
247 
248   void zrangeByScoreWithScores(string key, string min, string max,
249       int offset, int count);
250 
251   void zrevrangeByScore(string key, double max, double min);
252 
253   void zrevrangeByScore(string key, string max, string min);
254 
255   void zrevrangeByScore(string key, double max, double min, int offset,
256       int count);
257 
258   void zrevrangeByScore(string key, string max, string min, int offset, int count);
259 
260   void zrevrangeByScoreWithScores(string key, double max, double min);
261 
262   void zrevrangeByScoreWithScores(string key, double max, double min,
263       int offset, int count);
264 
265   void zrevrangeByScoreWithScores(string key, string max, string min);
266 
267   void zrevrangeByScoreWithScores(string key, string max, string min,
268       int offset, int count);
269 
270   void zremrangeByRank(string key, long start, long stop);
271 
272   void zremrangeByScore(string key, double min, double max);
273 
274   void zremrangeByScore(string key, string min, string max);
275 
276   void zunionstore(string dstkey, string[] sets...);
277 
278   void zunionstore(string dstkey, ZParams params, string[] sets...);
279 
280   void zinterstore(string dstkey, string[] sets...);
281 
282   void zinterstore(string dstkey, ZParams params, string[] sets...);
283 
284   void strlen(string key);
285 
286   void lpushx(string key, string[] string...);
287 
288   void persist(string key);
289 
290   void rpushx(string key, string[] string...);
291 
292   void echo(string string);
293 
294   void linsert(string key, ListPosition where, string pivot, string value);
295 
296   void bgrewriteaof();
297 
298   void bgsave();
299 
300   void lastsave();
301 
302   void save();
303 
304   void configSet(string parameter, string value);
305 
306   void configGet(string pattern);
307 
308   void configResetStat();
309 
310   void multi();
311 
312   void exec();
313 
314   void discard();
315 
316   void objectRefcount(string key);
317 
318   void objectIdletime(string key);
319 
320   void objectEncoding(string key);
321 
322   void bitcount(string key);
323 
324   void bitcount(string key, long start, long end);
325 
326   void bitop(BitOP op, string destKey, string[] srcKeys...);
327 
328   void dump(string key);
329 
330   void restore(string key, int ttl, const(ubyte)[] serializedValue);
331 
332   void restoreReplace(string key, int ttl, const(ubyte)[] serializedValue);
333 
334   void scan(string cursor, ScanParams params);
335 
336   void hscan(string key, string cursor, ScanParams params);
337 
338   void sscan(string key, string cursor, ScanParams params);
339 
340   void zscan(string key, string cursor, ScanParams params);
341 
342   void waitReplicas(int replicas, long timeout);
343 
344   /**
345    * Used for BITFIELD Redis command
346    * @param key
347    * @param arguments
348    */
349   void bitfield(string key, string[] arguments...);
350 
351   /**
352    * Used for HSTRLEN Redis command
353    * @param key
354    * @param field
355    */
356   void hstrlen(string key, string field);
357 
358   void migrate(string host, int port, string key, int destinationDB, int timeout);
359 
360   void migrate(string host, int port, int destinationDB, int timeout, MigrateParams params, string[] keys...);
361 
362   void clientKill(string ipPort);
363 
364   void clientKill(string ip, int port);
365 
366   void clientKill(ClientKillParams params);
367 
368   void clientGetname();
369 
370   void clientList();
371 
372   void clientSetname(string name);
373 
374   void memoryDoctor();
375 
376   void xadd(string key, StreamEntryID id, Map!(string, string) hash, long maxLen, bool approximateLength);
377   
378   void xlen(string key);
379 
380   void xrange(string key, StreamEntryID start, StreamEntryID end, long count);
381   
382   void xrevrange(string key, StreamEntryID end, StreamEntryID start, int count);
383   
384   void xread(int count, long block, MapEntry!(string, StreamEntryID)[] streams...);
385   
386   void xack(string key, string group, StreamEntryID[] ids...);
387   
388   void xgroupCreate(string key, string consumer, StreamEntryID id, bool makeStream);
389 
390   void xgroupSetID(string key, string consumer, StreamEntryID id);
391 
392   void xgroupDestroy(string key, string consumer);
393 
394   void xgroupDelConsumer(string key, string consumer, string consumerName);
395 
396   void xdel(string key, StreamEntryID[] ids...);
397 
398   void xtrim(string key, long maxLen, bool approximateLength);
399 
400   void xreadGroup(string groupname, string consumer, int count, long block, bool noAck, MapEntry!(string, StreamEntryID)[] streams...);
401 
402   void xpending(string key, string groupname, StreamEntryID start, StreamEntryID end, int count, string consumername);
403 
404   void xclaim(string key, string group, string consumername, long minIdleTime, long newIdleTime, int retries,
405       bool force, StreamEntryID[] ids...);
406 }