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.RedisPipeline;
13 
14 import hunt.redis.Protocol;
15 
16 import hunt.redis.StreamEntryID;
17 import hunt.redis.BitPosParams;
18 import hunt.redis.GeoCoordinate;
19 import hunt.redis.GeoRadiusResponse;
20 import hunt.redis.GeoUnit;
21 import hunt.redis.ListPosition;
22 import hunt.redis.StreamPendingEntry;
23 import hunt.redis.Response;
24 import hunt.redis.SortingParams;
25 import hunt.redis.StreamEntry;
26 import hunt.redis.Tuple;
27 import hunt.redis.params.GeoRadiusParam;
28 import hunt.redis.params.SetParams;
29 import hunt.redis.params.ZAddParams;
30 import hunt.redis.params.ZIncrByParams;
31 
32 import hunt.collection.List;
33 import hunt.collection.Map;
34 import hunt.collection.Set;
35 import hunt.Boolean;
36 import hunt.Double;
37 import hunt.Long;
38 
39 
40 interface RedisPipeline {
41   Response!(Long) append(string key, string value);
42 
43   Response!(List!(string)) blpop(string arg);
44 
45   Response!(List!(string)) brpop(string arg);
46 
47   Response!(Long) decr(string key);
48 
49   Response!(Long) decrBy(string key, long decrement);
50 
51   Response!(Long) del(string key);
52 
53   Response!(Long) unlink(string key);
54 
55   Response!(string) echo(string string);
56 
57   Response!(Boolean) exists(string key);
58 
59   Response!(Long) expire(string key, int seconds);
60 
61   Response!(Long) pexpire(string key, long milliseconds);
62 
63   Response!(Long) expireAt(string key, long unixTime);
64 
65   Response!(Long) pexpireAt(string key, long millisecondsTimestamp);
66 
67   Response!(string) get(string key);
68 
69   Response!(Boolean) getbit(string key, long offset);
70 
71   Response!(string) getrange(string key, long startOffset, long endOffset);
72 
73   Response!(string) getSet(string key, string value);
74 
75   Response!(Long) hdel(string key, string[] field...);
76 
77   Response!(Boolean) hexists(string key, string field);
78 
79   Response!(string) hget(string key, string field);
80 
81   Response!(Map!(string, string)) hgetAll(string key);
82 
83   Response!(Long) hincrBy(string key, string field, long value);
84 
85   Response!(Set!(string)) hkeys(string key);
86 
87   Response!(Long) hlen(string key);
88 
89   Response!(List!(string)) hmget(string key, string[] fields...);
90 
91   Response!(string) hmset(string key, Map!(string, string) hash);
92 
93   Response!(Long) hset(string key, string field, string value);
94 
95   Response!(Long) hset(string key, Map!(string, string) hash);
96 
97   Response!(Long) hsetnx(string key, string field, string value);
98 
99   Response!(List!(string)) hvals(string key);
100 
101   Response!(Long) incr(string key);
102 
103   Response!(Long) incrBy(string key, long increment);
104 
105   Response!(string) lindex(string key, long index);
106 
107   Response!(Long) linsert(string key, ListPosition where, string pivot, string value);
108 
109   Response!(Long) llen(string key);
110 
111   Response!(string) lpop(string key);
112 
113   Response!(Long) lpush(string key, string[] string...);
114 
115   Response!(Long) lpushx(string key, string[] string...);
116 
117   Response!(List!(string)) lrange(string key, long start, long stop);
118 
119   Response!(Long) lrem(string key, long count, string value);
120 
121   Response!(string) lset(string key, long index, string value);
122 
123   Response!(string) ltrim(string key, long start, long stop);
124 
125   Response!(Long) move(string key, int dbIndex);
126 
127   Response!(Long) persist(string key);
128 
129   Response!(string) rpop(string key);
130 
131   Response!(Long) rpush(string key, string[] string...);
132 
133   Response!(Long) rpushx(string key, string[] string...);
134 
135   Response!(Long) sadd(string key, string[] member...);
136 
137   Response!(Long) scard(string key);
138 
139   Response!(Boolean) sismember(string key, string member);
140 
141   Response!(string) set(string key, string value);
142 
143   Response!(Boolean) setbit(string key, long offset, bool value);
144 
145   Response!(string) setex(string key, int seconds, string value);
146 
147   Response!(Long) setnx(string key, string value);
148 
149   Response!(Long) setrange(string key, long offset, string value);
150 
151   Response!(Set!(string)) smembers(string key);
152 
153   Response!(List!(string)) sort(string key);
154 
155   Response!(List!(string)) sort(string key, SortingParams sortingParameters);
156 
157   Response!(string) spop(string key);
158 
159   Response!(Set!(string)) spop(string key, long count);
160 
161   Response!(string) srandmember(string key);
162 
163   Response!(Long) srem(string key, string[] member...);
164 
165   Response!(Long) strlen(string key);
166 
167   Response!(string) substr(string key, int start, int end);
168 
169   Response!(Long) touch(string key);
170 
171   Response!(Long) ttl(string key);
172 
173   Response!(Long) pttl(string key);
174 
175   Response!(string) type(string key);
176 
177   Response!(Long) zadd(string key, double score, string member);
178 
179   Response!(Long) zadd(string key, double score, string member, ZAddParams params);
180 
181   Response!(Long) zadd(string key, Map!(string, double) scoreMembers);
182 
183   Response!(Long) zadd(string key, Map!(string, double) scoreMembers, ZAddParams params);
184 
185   Response!(Long) zcard(string key);
186 
187   Response!(Long) zcount(string key, double min, double max);
188 
189   Response!(Long) zcount(string key, string min, string max);
190 
191   Response!(Double) zincrby(string key, double increment, string member);
192 
193   Response!(Double) zincrby(string key, double increment, string member, ZIncrByParams params);
194 
195   Response!(Set!(string)) zrange(string key, long start, long stop);
196 
197   Response!(Set!(string)) zrangeByScore(string key, double min, double max);
198 
199   Response!(Set!(string)) zrangeByScore(string key, string min, string max);
200 
201   Response!(Set!(string)) zrangeByScore(string key, double min, double max, int offset, int count);
202 
203   Response!(Set!(string)) zrangeByScore(string key, string min, string max, int offset, int count);
204 
205   Response!(Set!(Tuple)) zrangeByScoreWithScores(string key, double min, double max);
206 
207   Response!(Set!(Tuple)) zrangeByScoreWithScores(string key, double min, double max, int offset,
208       int count);
209 
210   Response!(Set!(string)) zrevrangeByScore(string key, double max, double min);
211 
212   Response!(Set!(string)) zrevrangeByScore(string key, string max, string min);
213 
214   Response!(Set!(string)) zrevrangeByScore(string key, double max, double min, int offset, int count);
215 
216   Response!(Set!(string)) zrevrangeByScore(string key, string max, string min, int offset, int count);
217 
218   Response!(Set!(Tuple)) zrevrangeByScoreWithScores(string key, double max, double min);
219 
220   Response!(Set!(Tuple)) zrevrangeByScoreWithScores(string key, string max, string min);
221 
222   Response!(Set!(Tuple)) zrevrangeByScoreWithScores(string key, double max, double min, int offset,
223       int count);
224 
225   Response!(Set!(Tuple)) zrevrangeByScoreWithScores(string key, string max, string min, int offset,
226       int count);
227 
228   Response!(Set!(Tuple)) zrangeWithScores(string key, long start, long stop);
229 
230   Response!(Long) zrank(string key, string member);
231 
232   Response!(Long) zrem(string key, string[] members...);
233 
234   Response!(Long) zremrangeByRank(string key, long start, long stop);
235 
236   Response!(Long) zremrangeByScore(string key, double min, double max);
237 
238   Response!(Long) zremrangeByScore(string key, string min, string max);
239 
240   Response!(Set!(string)) zrevrange(string key, long start, long stop);
241 
242   Response!(Set!(Tuple)) zrevrangeWithScores(string key, long start, long stop);
243 
244   Response!(Long) zrevrank(string key, string member);
245 
246   Response!(Double) zscore(string key, string member);
247 
248   Response!(Long) zlexcount(string key, string min, string max);
249 
250   Response!(Set!(string)) zrangeByLex(string key, string min, string max);
251 
252   Response!(Set!(string)) zrangeByLex(string key, string min, string max,
253       int offset, int count);
254 
255   Response!(Set!(string)) zrevrangeByLex(string key, string max, string min);
256 
257   Response!(Set!(string)) zrevrangeByLex(string key, string max, string min,
258       int offset, int count);
259 
260   Response!(Long) zremrangeByLex(string key, string min, string max);
261 
262   Response!(Long) bitcount(string key);
263 
264   Response!(Long) bitcount(string key, long start, long end);
265 
266   Response!(Long) pfadd(string key, string[] elements...);
267 
268   Response!(Long) pfcount(string key);
269   
270   Response!(List!(Long)) bitfield(string key, string[] arguments...);
271   
272   Response!(Long) hstrlen(string key, string field);
273 
274   Response!(const(ubyte)[]) dump(string key);
275 
276   Response!(string) restore(string key, int ttl, const(ubyte)[] serializedValue);
277 
278   Response!(string) restoreReplace(string key, int ttl, const(ubyte)[] serializedValue);
279 
280   Response!(string) migrate(string host, int port, string key, int destinationDB, int timeout);
281 
282   // Geo Commands
283 
284   Response!(Long) geoadd(string key, double longitude, double latitude, string member);
285 
286   Response!(Long) geoadd(string key, Map!(string, GeoCoordinate) memberCoordinateMap);
287 
288   Response!(Double) geodist(string key, string member1, string member2);
289 
290   Response!(Double) geodist(string key, string member1, string member2, GeoUnit unit);
291 
292   Response!(List!(string)) geohash(string key, string[] members...);
293 
294   Response!(List!(GeoCoordinate)) geopos(string key, string[] members...);
295 
296   Response!(List!(GeoRadiusResponse)) georadius(string key, double longitude, double latitude,
297       double radius, GeoUnit unit);
298 
299   Response!(List!(GeoRadiusResponse)) georadiusReadonly(string key, double longitude, double latitude,
300       double radius, GeoUnit unit);
301 
302   Response!(List!(GeoRadiusResponse)) georadius(string key, double longitude, double latitude,
303       double radius, GeoUnit unit, GeoRadiusParam param);
304 
305   Response!(List!(GeoRadiusResponse)) georadiusReadonly(string key, double longitude, double latitude,
306       double radius, GeoUnit unit, GeoRadiusParam param);
307 
308   Response!(List!(GeoRadiusResponse)) georadiusByMember(string key, string member, double radius,
309       GeoUnit unit);
310 
311   Response!(List!(GeoRadiusResponse)) georadiusByMemberReadonly(string key, string member, double radius,
312       GeoUnit unit);
313 
314   Response!(List!(GeoRadiusResponse)) georadiusByMember(string key, string member, double radius,
315       GeoUnit unit, GeoRadiusParam param);
316 
317   Response!(List!(GeoRadiusResponse)) georadiusByMemberReadonly(string key, string member, double radius,
318       GeoUnit unit, GeoRadiusParam param);
319   
320   Response!(StreamEntryID) xadd(string key, StreamEntryID id, Map!(string, string) hash);
321 
322   Response!(StreamEntryID) xadd(string key, StreamEntryID id, Map!(string, string) hash, long maxLen, bool approximateLength);
323   
324   Response!(Long) xlen(string key);
325 
326   Response!(List!(StreamEntry)) xrange(string key, StreamEntryID start, StreamEntryID end, int count);
327 
328   Response!(List!(StreamEntry)) xrevrange(string key, StreamEntryID end, StreamEntryID start, int count);
329    
330   Response!(Long) xack(string key, string group,  StreamEntryID[] ids...);
331   
332   Response!(string) xgroupCreate( string key, string groupname, StreamEntryID id, bool makeStream);
333   
334   Response!(string) xgroupSetID( string key, string groupname, StreamEntryID id);
335   
336   Response!(Long) xgroupDestroy( string key, string groupname);
337   
338   Response!(string) xgroupDelConsumer( string key, string groupname, string consumername);
339 
340   Response!(List!(StreamPendingEntry)) xpending(string key, string groupname, StreamEntryID start, StreamEntryID end, int count, string consumername);
341   
342   Response!(Long) xdel( string key, StreamEntryID[] ids...);
343   
344   Response!(Long) xtrim( string key, long maxLen, bool approximateLength);
345  
346   Response!(List!(StreamEntry)) xclaim( string key, string group, string consumername, long minIdleTime, 
347       long newIdleTime, int retries, bool force, StreamEntryID[] ids...);
348 
349   Response!(Long) bitpos(string key, bool value);
350 
351   Response!(Long) bitpos(string key, bool value, BitPosParams params);
352 
353   Response!(string) set(string key, string value, SetParams params);
354 
355   Response!(List!(string)) srandmember(string key, int count);
356 
357   Response!(Set!(Tuple)) zrangeByScoreWithScores(string key, string min, string max);
358 
359   Response!(Set!(Tuple)) zrangeByScoreWithScores(string key, string min, string max, int offset,
360       int count);
361 
362   Response!(Long) objectRefcount(string key);
363 
364   Response!(string) objectEncoding(string key);
365 
366   Response!(Long) objectIdletime(string key);
367 
368   Response!(Double) incrByFloat(string key, double increment);
369 
370   Response!(string) psetex(string key, long milliseconds, string value);
371 
372   Response!(Double) hincrByFloat(string key, string field, double increment);
373 
374   Response!(Object) sendCommand(ProtocolCommand cmd, string[] args...);
375 }