Arduino-Redis
A Redis library for Arduino.
Redis.cpp
Go to the documentation of this file.
1 #include "Redis.h"
2 #include "RedisInternal.h"
3 
4 RedisReturnValue Redis::authenticate(const char *password)
5 {
6  if (conn.connected())
7  {
8  int passwordLength = strlen(password);
9  if (passwordLength > 0)
10  {
11  auto cmdRet = RedisCommand("AUTH", ArgList{password}).issue(conn);
12  return cmdRet->type() == RedisObject::Type::SimpleString && (String)*cmdRet == "OK"
13  ? RedisSuccess
15  }
16 
17  return RedisSuccess;
18  }
19 
21 }
22 
23 #define TRCMD(t, c, ...) return RedisCommand(c, ArgList{__VA_ARGS__}).issue_typed<t>(conn)
24 
25 #define TRCMD_EXPECTOK(c, ...) return (bool)(((String)*RedisCommand(c, ArgList{__VA_ARGS__}).issue(conn)).indexOf("OK") != -1)
26 
27 bool Redis::set(const char *key, const char *value)
28 {
29  TRCMD_EXPECTOK("SET", key, value);
30 }
31 
32 String Redis::get(const char *key)
33 {
34  TRCMD(String, "GET", key);
35 }
36 
37 bool Redis::del(const char *key)
38 {
39  TRCMD(bool, "DEL", key);
40 }
41 
42 int Redis::append(const char *key, const char *value)
43 {
44  TRCMD(int, "APPEND", key, value);
45 }
46 
47 int Redis::publish(const char *channel, const char *message)
48 {
49  TRCMD(int, "PUBLISH", channel, message);
50 }
51 
52 bool Redis::exists(const char *key)
53 {
54  TRCMD(bool, "EXISTS", key);
55 }
56 
57 bool Redis::_expire_(const char *key, int arg, const char *cmd_var)
58 {
59  TRCMD(bool, cmd_var, key, String(arg));
60 }
61 
62 bool Redis::persist(const char *key)
63 {
64  TRCMD(bool, "PERSIST", key);
65 }
66 
67 int Redis::_ttl_(const char *key, const char *cmd_var)
68 {
69  TRCMD(int, cmd_var, key);
70 }
71 
72 bool Redis::_hset_(const char *key, const char *field, const char *value, const char *cmd_var)
73 {
74  TRCMD(int, cmd_var, key, field, value);
75 }
76 
77 String Redis::hget(const char *key, const char *field)
78 {
79  TRCMD(String, "HGET", key, field);
80 }
81 
82 bool Redis::hdel(const char *key, const char *field)
83 {
84  TRCMD(bool, "HDEL", key, field);
85 }
86 
87 int Redis::hlen(const char *key)
88 {
89  TRCMD(int, "HLEN", key);
90 }
91 
92 int Redis::hstrlen(const char *key, const char *field)
93 {
94  TRCMD(int, "HSTRLEN", key, field);
95 }
96 
97 bool Redis::hexists(const char *key, const char *field)
98 {
99  TRCMD(bool, "HEXISTS", key, field);
100 }
101 
102 std::vector<String> Redis::lrange(const char *key, int start, int stop)
103 {
104  auto rv = RedisCommand("LRANGE", ArgList{key, String(start), String(stop)}).issue(conn);
105 
106  if(rv->type() == RedisObject::Type::InternalError)
107  {
108  std::vector<String> r = std::vector<String>();
109  String error_message = (String)(((RedisInternalError *)rv.get())->RESP());
110  r.push_back(error_message);
111  return r;
112  }
113  else
114  {
115  return rv->type() == RedisObject::Type::Array
116  ? (std::vector<String>)*((RedisArray *)rv.get())
117  : std::vector<String>();
118  }
119 }
120 
121 String Redis::lindex(const char *key, int index)
122 {
123  TRCMD(String, "LINDEX", key, String(index));
124 }
125 
126 int Redis::llen(const char *key)
127 {
128  TRCMD(int, "LLEN", key);
129 }
130 
131 String Redis::lpop(const char *key)
132 {
133  TRCMD(String, "LPOP", key);
134 }
135 
136 int Redis::lpos(const char *key, const char *element)
137 {
138  TRCMD(int, "LPOS", key, element);
139 }
140 
141 int Redis::lpush(const char *key, const char *value, bool exclusive)
142 {
143  TRCMD(int, (exclusive ? "LPUSHX" : "LPUSH"), key, value);
144 }
145 
146 int Redis::lrem(const char *key, int count, const char *element)
147 {
148  TRCMD(int, "LREM", key, String(count), element);
149 }
150 
151 bool Redis::lset(const char *key, int index, const char *element)
152 {
153  TRCMD_EXPECTOK("LSET", key, String(index), element);
154 }
155 
156 bool Redis::ltrim(const char *key, int start, int stop)
157 {
158  TRCMD_EXPECTOK("LTRIM", key, String(start), String(stop));
159 }
160 
161 bool Redis::tsadd(const char *key, long timestamp, const int value)
162 {
163  if (timestamp < 0)
164  {
165  TRCMD_EXPECTOK("TS.ADD", key, "*", String(value));
166  }
167  else
168  {
169  TRCMD_EXPECTOK("TS.ADD", key, String(timestamp) + "000", String(value));
170  }
171 }
172 
173 int Redis::xack(const char *key, const char *group, const char *id)
174 {
175  TRCMD(int, "XACK", key, group, id);
176 }
177 
178 String Redis::xadd(const char *key, const char *id, const char *field,
179  const char *value)
180 {
181  TRCMD(String, "XADD", key, id, field, value);
182 }
183 
184 std::vector<String> Redis::xautoclaim(const char *key, const char* group,
185  const char* consumer, unsigned int min_idle_time, const char *start,
186  unsigned int count, bool justid)
187 {
188  ArgList argList = ArgList{key, group, consumer, String(min_idle_time), start};
189 
190  if(count > 0)
191  {
192  argList.push_back("COUNT");
193  argList.push_back(String(count));
194  }
195 
196  if(justid == true)
197  {
198  argList.push_back("JUSTID");
199  }
200 
201  auto rv = RedisCommand("XAUTOCLAIM", argList).issue(conn);
202 
203  if(rv->type() == RedisObject::Type::InternalError)
204  {
205  std::vector<String> r = std::vector<String>();
206  String error_message = (String)(((RedisInternalError *)rv.get())->RESP());
207  r.push_back(error_message);
208  return r;
209  }
210  else
211  {
212  return rv->type() == RedisObject::Type::Array
213  ? (std::vector<String>)*((RedisArray *)rv.get())
214  : std::vector<String>();
215  }
216 }
217 
218 std::vector<String> Redis::xclaim(const char *key, const char *group,
219  const char *consumer, unsigned int min_idle_time, const char *id,
220  unsigned int idle_ms, unsigned int time_ms, unsigned int retrycount,
221  bool force, bool justid, const char *lastid)
222 {
223  ArgList argList = ArgList{key, group, consumer, String(min_idle_time), id};
224 
225  if(idle_ms > 0)
226  {
227  argList.push_back("IDLE");
228  argList.push_back(String(idle_ms));
229  }
230 
231  if(time_ms > 0)
232  {
233  argList.push_back("TIME");
234  argList.push_back(String(time_ms));
235  }
236 
237  if(retrycount > 0)
238  {
239  argList.push_back("RETRYCOUNT");
240  argList.push_back(String(retrycount));
241  }
242 
243  if(force == true)
244  {
245  argList.push_back("FORCE");
246  }
247 
248  if(justid == true)
249  {
250  argList.push_back("JUSTID");
251  }
252 
253  if(lastid != NULL && strlen(lastid) > 0)
254  {
255  argList.push_back("LASTID");
256  argList.push_back(lastid);
257  }
258 
259  auto rv = RedisCommand("XCLAIM", argList).issue(conn);
260 
261  if(rv->type() == RedisObject::Type::InternalError)
262  {
263  std::vector<String> r = std::vector<String>();
264  String error_message = (String)(((RedisInternalError *)rv.get())->RESP());
265  r.push_back(error_message);
266  return r;
267  }
268  else
269  {
270  return rv->type() == RedisObject::Type::Array
271  ? (std::vector<String>)*((RedisArray *)rv.get())
272  : std::vector<String>();
273  }
274 }
275 
276 int Redis::xdel(const char *key, const char *id)
277 {
278  TRCMD(int, "XDEL", key, id);
279 }
280 
281 bool Redis::xgroup_create(const char *key, const char *group, const char *id,
282  bool mkstream)
283 {
284  if(mkstream)
285  {
286  TRCMD_EXPECTOK("XGROUP", "CREATE", key, group, id, "MKSTREAM");
287  }
288  else
289  {
290  TRCMD_EXPECTOK("XGROUP", "CREATE", key, group, id);
291  }
292 }
293 
294 int Redis::xgroup_createconsumer(const char *key, const char *group,
295  const char *consumer)
296 {
297  TRCMD(int, "XGROUP", "CREATECONSUMER", key, group, consumer);
298 }
299 
300 int Redis::xgroup_delconsumer(const char *key, const char *group,
301  const char *consumer)
302 {
303  TRCMD(int, "XGROUP", "DELCONSUMER", key, group, consumer);
304 }
305 
306 int Redis::xgroup_destroy(const char *key, const char *group)
307 {
308  TRCMD(int, "XGROUP", "DESTROY", key, group);
309 }
310 
311 bool Redis::xgroup_setid(const char* key, const char *group, const char *id)
312 {
313  TRCMD_EXPECTOK("XGROUP", "SETID", key, group, id);
314 }
315 
316 std::vector<String> Redis::xinfo_consumers(const char *key, const char* group)
317 {
318  auto rv = RedisCommand("XINFO", ArgList{"CONSUMERS", key, group}).issue(conn);
319 
320  if(rv->type() == RedisObject::Type::InternalError)
321  {
322  std::vector<String> r = std::vector<String>();
323  String error_message = (String)(((RedisInternalError *)rv.get())->RESP());
324  r.push_back(error_message);
325  return r;
326  }
327  else
328  {
329  return rv->type() == RedisObject::Type::Array
330  ? (std::vector<String>)*((RedisArray *)rv.get())
331  : std::vector<String>();
332  }
333 }
334 
335 std::vector<String> Redis::xinfo_groups(const char *key)
336 {
337  auto rv = RedisCommand("XINFO", ArgList{"GROUPS", key}).issue(conn);
338 
339  if(rv->type() == RedisObject::Type::InternalError)
340  {
341  std::vector<String> r = std::vector<String>();
342  String error_message = (String)(((RedisInternalError *)rv.get())->RESP());
343  r.push_back(error_message);
344  return r;
345  }
346  else
347  {
348  return rv->type() == RedisObject::Type::Array
349  ? (std::vector<String>)*((RedisArray *)rv.get())
350  : std::vector<String>();
351  }
352 }
353 
354 std::vector<String> Redis::xinfo_stream(const char *key, bool full,
355  unsigned int count)
356 {
357  ArgList argList = ArgList{"STREAM", key};
358 
359  if(full == true)
360  {
361  argList.push_back("FULL");
362 
363  if(count > 0)
364  {
365  argList.push_back("COUNT");
366  argList.push_back(String(count));
367  }
368  }
369 
370  auto rv = RedisCommand("XINFO", argList).issue(conn);
371 
372  if(rv->type() == RedisObject::Type::InternalError)
373  {
374  std::vector<String> r = std::vector<String>();
375  String error_message = (String)(((RedisInternalError *)rv.get())->RESP());
376  r.push_back(error_message);
377  return r;
378  }
379  else
380  {
381  return rv->type() == RedisObject::Type::Array
382  ? (std::vector<String>)*((RedisArray *)rv.get())
383  : std::vector<String>();
384  }
385 }
386 
387 int Redis::xlen(const char *key)
388 {
389  TRCMD(int, "XLEN", key);
390 }
391 
392 std::vector<String> Redis::xpending(const char *key, const char* group,
393  unsigned int min_idle_time, const char *start, const char *end,
394  unsigned int count, const char *consumer)
395 {
396  ArgList argList = ArgList{key, group};
397 
398  if(min_idle_time > 0)
399  {
400  argList.push_back("IDLE");
401  argList.push_back(String(min_idle_time));
402  }
403 
404  if(start != NULL && strlen(start) > 0 && end != NULL && strlen(end) > 0)
405  {
406  argList.push_back(start);
407  argList.push_back(end);
408  argList.push_back(String(count));
409  }
410 
411  if(consumer != NULL && strlen(consumer) > 0)
412  {
413  argList.push_back(consumer);
414  }
415 
416  auto rv = RedisCommand("XPENDING", argList).issue(conn);
417 
418  if(rv->type() == RedisObject::Type::InternalError)
419  {
420  std::vector<String> r = std::vector<String>();
421  String error_message = (String)(((RedisInternalError *)rv.get())->RESP());
422  r.push_back(error_message);
423  return r;
424  }
425  else
426  {
427  return rv->type() == RedisObject::Type::Array
428  ? (std::vector<String>)*((RedisArray *)rv.get())
429  : std::vector<String>();
430  }
431 }
432 
433 std::vector<String> Redis::xrange(const char *key, const char *start,
434  const char *end, unsigned int count)
435 {
436  ArgList argList = ArgList{key, start, end};
437 
438  if(count > 0)
439  {
440  argList.push_back("COUNT");
441  argList.push_back(String(count));
442  }
443 
444  auto rv = RedisCommand("XRANGE", argList).issue(conn);
445 
446  if(rv->type() == RedisObject::Type::InternalError)
447  {
448  std::vector<String> r = std::vector<String>();
449  String error_message = (String)(((RedisInternalError *)rv.get())->RESP());
450  r.push_back(error_message);
451  return r;
452  }
453  else
454  {
455  return rv->type() == RedisObject::Type::Array
456  ? (std::vector<String>)*((RedisArray *)rv.get())
457  : std::vector<String>();
458  }
459 }
460 
461 std::vector<String> Redis::xread(unsigned int count, unsigned int block,
462  const char *key, const char *id)
463 {
464  ArgList argList = std::vector<String>();
465 
466  if(count > 0)
467  {
468  argList.push_back("COUNT");
469  argList.push_back(String(count));
470  }
471 
472  if(block > 0)
473  {
474  argList.push_back("BLOCK");
475  argList.push_back(String(block));
476  }
477 
478  argList.push_back("STREAMS");
479  argList.push_back(key);
480  argList.push_back(id);
481 
482  auto rv = RedisCommand("XREAD", argList).issue(conn);
483 
484  if(rv->type() == RedisObject::Type::InternalError)
485  {
486  std::vector<String> r = std::vector<String>();
487  String error_message = (String)(((RedisInternalError *)rv.get())->RESP());
488  r.push_back(error_message);
489  return r;
490  }
491  else
492  {
493  return rv->type() == RedisObject::Type::Array
494  ? (std::vector<String>)*((RedisArray *)rv.get())
495  : std::vector<String>();
496  }
497 }
498 
499 std::vector<String> Redis::xreadgroup(const char *group, const char *consumer,
500  unsigned int count, unsigned int block_ms, bool noack, const char *key,
501  const char *id)
502 {
503  ArgList argList = ArgList{"GROUP", group, consumer};
504 
505  if(count > 0)
506  {
507  argList.push_back("COUNT");
508  argList.push_back(String(count));
509  }
510 
511  if(block_ms > 0)
512  {
513  argList.push_back("BLOCK");
514  argList.push_back(String(block_ms));
515  }
516 
517  if(noack == true)
518  {
519  argList.push_back("NOACK");
520  }
521 
522  if(key != NULL && strlen(key) > 0)
523  {
524  argList.push_back("STREAMS");
525  argList.push_back(key);
526  }
527 
528  argList.push_back(id);
529 
530  auto rv = RedisCommand("XREADGROUP", argList).issue(conn);
531 
532  if(rv->type() == RedisObject::Type::InternalError)
533  {
534  std::vector<String> r = std::vector<String>();
535  String error_message = (String)(((RedisInternalError *)rv.get())->RESP());
536  r.push_back(error_message);
537  return r;
538  }
539  else
540  {
541  return rv->type() == RedisObject::Type::Array
542  ? (std::vector<String>)*((RedisArray *)rv.get())
543  : std::vector<String>();
544  }
545 }
546 
547 std::vector<String> Redis::xrevrange(const char *key, const char *end,
548  const char *start, unsigned int count)
549 {
550  ArgList argList = ArgList{key, end, start};
551 
552  if(count > 0)
553  {
554  argList.push_back("COUNT");
555  argList.push_back(String(count));
556  }
557 
558  auto rv = RedisCommand("XREVRANGE", argList).issue(conn);
559 
560  if(rv->type() == RedisObject::Type::InternalError)
561  {
562  std::vector<String> r = std::vector<String>();
563  String error_message = (String)(((RedisInternalError *)rv.get())->RESP());
564  r.push_back(error_message);
565  return r;
566  }
567  else
568  {
569  return rv->type() == RedisObject::Type::Array
570  ? (std::vector<String>)*((RedisArray *)rv.get())
571  : std::vector<String>();
572  }
573 }
574 
575 int Redis::xtrim(const char *key, const char *strategy, XtrimCompareType compare,
576  const int threshold, const int count)
577 {
578  if(compare == XtrimCompareAtLeast)
579  {
580  if(count > 0)
581  {
582  TRCMD(int, "XTRIM", key, strategy, String(char(compare)),
583  String(threshold), "LIMIT", String(count));
584  }
585  else
586  {
587  TRCMD(int, "XTRIM", key, strategy, String(threshold));
588  }
589  }
590  else
591  {
592  TRCMD(int, "XTRIM", key, strategy, String(char(compare)),
593  String(threshold));
594  }
595 }
596 
597 String Redis::info(const char *section)
598 {
599  TRCMD(String, "INFO", (section ? section : ""));
600 }
601 
602 String Redis::rpop(const char *key)
603 {
604  TRCMD(String, "RPOP", key);
605 }
606 
607 int Redis::rpush(const char *key, const char *value, bool exclusive)
608 {
609  TRCMD(int, (exclusive ? "RPUSHX" : "RPUSH"), key, value);
610 }
611 
612 bool Redis::_subscribe(SubscribeSpec spec)
613 {
614  if (!subscriberMode)
615  {
616  subSpec.push_back(spec);
617  return true;
618  }
619 
620  const char *cmdName = spec.pattern ? "PSUBSCRIBE" : "SUBSCRIBE";
621  auto rv = RedisCommand(cmdName, ArgList{spec.spec}).issue(conn);
622  return rv->type() == RedisObject::Type::Array;
623 }
624 
625 bool Redis::unsubscribe(const char *channelOrPattern)
626 {
627  auto rv = RedisCommand("UNSUBSCRIBE", ArgList{channelOrPattern}).issue(conn);
628 
629  if (rv->type() == RedisObject::Type::Array)
630  {
631  auto vec = (std::vector<String>)*((RedisArray *)rv.get());
632  return vec.size() == 3 && vec[1] == String(channelOrPattern);
633  }
634 
635  return false;
636 }
637 
638 RedisSubscribeResult Redis::startSubscribingNonBlocking(RedisMsgCallback messageCallback, LoopCallback loopCallback, RedisMsgErrorCallback errCallback)
639 {
640  if (!messageCallback)
641  {
643  }
644 
645  bool success = true;
646  subscriberMode = true;
647  if (subSpec.size())
648  {
649  for (auto spec : subSpec)
650  {
651  success = _subscribe(spec) && success;
652  }
653  }
654 
655  if (!success)
656  {
658  }
659 
660  auto emitErr = [=](RedisMessageError errCode) -> void
661  {
662  if (errCallback)
663  {
664  errCallback(this, errCode);
665  }
666  };
667 
668  subLoopRun = true;
669  while (subLoopRun)
670  {
671  loopCallback();
672  auto msg = RedisObject::parseTypeNonBlocking(conn);
673  if (msg == nullptr) {
674  continue;
675  }
676 
677  if (msg->type() == RedisObject::Type::InternalError)
678  {
679  auto errPtr = (RedisInternalError *)msg.get();
680 
681  if (errPtr->code() == RedisInternalError::Disconnected)
682  {
684  }
685 
687  }
688 
689  if (msg->type() != RedisObject::Type::Array)
690  {
692  continue;
693  }
694 
695  auto msgVec = (std::vector<String>)*((RedisArray *)msg.get());
696 
697  if (msgVec.size() < 3)
698  {
700  continue;
701  }
702 
703  if (msgVec[0] != "message" && msgVec[0] != "pmessage")
704  {
705  emitErr(RedisMessageUnknownType);
706  continue;
707  }
708 
709  // pmessage payloads have an extra paramter at index 1 that specifies the matched pattern; we ignore it here
710  auto pMsgAdd = msgVec[0] == "pmessage" ? 1 : 0;
711  messageCallback(this, msgVec[1 + pMsgAdd], msgVec[2 + pMsgAdd]);
712  }
713 
714  return RedisSubscribeSuccess;
715 }
716 
717 RedisSubscribeResult Redis::startSubscribing(RedisMsgCallback messageCallback, RedisMsgErrorCallback errCallback)
718 {
719  return startSubscribingNonBlocking(messageCallback, []{}, errCallback);
720 }
721 
722 bool Redis::isErrorReturn(std::vector<String>& returnVec) {
723  return ((returnVec[0].c_str())[0] == '-');
724 }
Redis::xgroup_setid
bool xgroup_setid(const char *key, const char *group, const char *id)
Definition: Redis.cpp:311
Redis::lset
bool lset(const char *key, int index, const char *element)
Definition: Redis.cpp:151
RedisMessageError
RedisMessageError
Definition: Redis.h:60
RedisCommand::issue
std::shared_ptr< RedisObject > issue(Client &cmdClient)
Definition: RedisInternal.cpp:101
Redis::hget
String hget(const char *key, const char *field)
Definition: Redis.cpp:77
Redis::xlen
int xlen(const char *key)
Definition: Redis.cpp:387
RedisMessageBadResponseType
@ RedisMessageBadResponseType
The underlying Redis type detected in the message is not of the type expected.
Definition: Redis.h:63
Redis::xpending
std::vector< String > xpending(const char *key, const char *group, unsigned int min_idle_time, const char *start, const char *end, unsigned int count, const char *consumer)
Definition: Redis.cpp:392
RedisCommand
Definition: RedisInternal.h:158
Redis::del
bool del(const char *key)
Definition: Redis.cpp:37
RedisAuthFailure
@ RedisAuthFailure
The authentication credentials used are not valid.
Definition: Redis.h:42
Redis::lpush
int lpush(const char *key, const char *value, bool exclusive=false)
Definition: Redis.cpp:141
Redis::get
String get(const char *key)
Definition: Redis.cpp:32
RedisMessageUnknownType
@ RedisMessageUnknownType
An unknown error occurred.
Definition: Redis.h:67
Redis::xgroup_destroy
int xgroup_destroy(const char *key, const char *group)
Definition: Redis.cpp:306
RedisSuccess
@ RedisSuccess
Definition: Redis.h:38
Redis::startSubscribing
RedisSubscribeResult startSubscribing(RedisMsgCallback messageCallback, RedisMsgErrorCallback errorCallback=nullptr)
Definition: Redis.cpp:717
Redis::xdel
int xdel(const char *key, const char *id)
Definition: Redis.cpp:276
Redis::xadd
String xadd(const char *key, const char *id, const char *field, const char *value)
Definition: Redis.cpp:178
Redis::xack
int xack(const char *key, const char *group, const char *id)
Definition: Redis.cpp:173
Redis::xgroup_createconsumer
int xgroup_createconsumer(const char *key, const char *group, const char *consumer)
Definition: Redis.cpp:294
RedisObject::parseTypeNonBlocking
static std::shared_ptr< RedisObject > parseTypeNonBlocking(Client &)
Definition: RedisInternal.cpp:154
Redis::xinfo_consumers
std::vector< String > xinfo_consumers(const char *key, const char *group)
Definition: Redis.cpp:316
Redis::unsubscribe
bool unsubscribe(const char *channelOrPattern)
Definition: Redis.cpp:625
RedisSubscribeSetupFailure
@ RedisSubscribeSetupFailure
Setting up for subscription mode failed.
Definition: Redis.h:51
RedisSubscribeSuccess
@ RedisSubscribeSuccess
Definition: Redis.h:56
RedisInternalError::Disconnected
@ Disconnected
Definition: RedisInternal.h:140
RedisSubscribeResult
RedisSubscribeResult
Definition: Redis.h:46
Redis::xrange
std::vector< String > xrange(const char *key, const char *start, const char *end, unsigned int count)
Definition: Redis.cpp:433
Redis::startSubscribingNonBlocking
RedisSubscribeResult startSubscribingNonBlocking(RedisMsgCallback messageCallback, LoopCallback loopCallback, RedisMsgErrorCallback errorCallback=nullptr)
Definition: Redis.cpp:638
Redis::publish
int publish(const char *channel, const char *message)
Definition: Redis.cpp:47
RedisMessageTruncatedResponse
@ RedisMessageTruncatedResponse
The message response was truncated early.
Definition: Redis.h:65
Redis::persist
bool persist(const char *key)
Definition: Redis.cpp:62
RedisArray
Definition: RedisInternal.h:91
Redis::lrange
std::vector< String > lrange(const char *key, int start, int stop)
Definition: Redis.cpp:102
RedisInternal.h
Redis::rpush
int rpush(const char *key, const char *value, bool exclusive=false)
Definition: Redis.cpp:607
RedisInternalError
Definition: RedisInternal.h:133
Redis::xreadgroup
std::vector< String > xreadgroup(const char *group, const char *consumer, unsigned int count, unsigned int block_ms, bool noack, const char *key, const char *id)
Definition: Redis.cpp:499
Redis::xinfo_stream
std::vector< String > xinfo_stream(const char *key, bool full, unsigned int count)
Definition: Redis.cpp:354
Redis::authenticate
RedisReturnValue authenticate(const char *password)
Definition: Redis.cpp:4
Redis::lpop
String lpop(const char *key)
Definition: Redis.cpp:131
Redis::tsadd
bool tsadd(const char *key, long timestamp, const int value)
Definition: Redis.cpp:161
XtrimCompareType
XtrimCompareType
Definition: Redis.h:73
TRCMD
#define TRCMD(t, c,...)
Definition: Redis.cpp:23
Redis::lpos
int lpos(const char *key, const char *element)
Definition: Redis.cpp:136
ArgList
std::vector< String > ArgList
Definition: RedisInternal.h:12
TRCMD_EXPECTOK
#define TRCMD_EXPECTOK(c,...)
Definition: Redis.cpp:25
RedisSubscribeOtherError
@ RedisSubscribeOtherError
An unknown error occurred.
Definition: Redis.h:55
Redis::isErrorReturn
bool isErrorReturn(std::vector< String > &returnVec)
Definition: Redis.cpp:722
RedisSubscribeBadCallback
@ RedisSubscribeBadCallback
One of the callback parameters given is invalid.
Definition: Redis.h:49
Redis::xgroup_create
bool xgroup_create(const char *key, const char *group, const char *id, bool mkstream)
Definition: Redis.cpp:281
Redis::exists
bool exists(const char *key)
Definition: Redis.cpp:52
XtrimCompareAtLeast
@ XtrimCompareAtLeast
Definition: Redis.h:76
Redis::xgroup_delconsumer
int xgroup_delconsumer(const char *key, const char *group, const char *consumer)
Definition: Redis.cpp:300
RedisNotConnectedFailure
@ RedisNotConnectedFailure
Authenticate attempted before the connection has been established.
Definition: Redis.h:40
Redis::lindex
String lindex(const char *key, int index)
Definition: Redis.cpp:121
Redis::hstrlen
int hstrlen(const char *key, const char *field)
Definition: Redis.cpp:92
Redis::xinfo_groups
std::vector< String > xinfo_groups(const char *key)
Definition: Redis.cpp:335
Redis::hdel
bool hdel(const char *key, const char *field)
Definition: Redis.cpp:82
Redis.h
Redis::xclaim
std::vector< String > xclaim(const char *key, const char *group, const char *consumer, unsigned int min_idle_time, const char *id, unsigned int idle_ms, unsigned int time_ms, unsigned int retrycount, bool force, bool justid, const char *lastid)
Definition: Redis.cpp:218
RedisSubscribeServerDisconnected
@ RedisSubscribeServerDisconnected
The remote end disconnected, retry may be available.
Definition: Redis.h:53
Redis::llen
int llen(const char *key)
Definition: Redis.cpp:126
Redis::hexists
bool hexists(const char *key, const char *field)
Definition: Redis.cpp:97
Redis::xtrim
int xtrim(const char *key, const char *strategy, XtrimCompareType compare, int threshold, int count)
Definition: Redis.cpp:575
RedisReturnValue
RedisReturnValue
Definition: Redis.h:36
Redis::xautoclaim
std::vector< String > xautoclaim(const char *key, const char *group, const char *consumer, unsigned int min_idle_time, const char *start, unsigned int count, bool justid)
Definition: Redis.cpp:184
Redis::append
int append(const char *key, const char *value)
Definition: Redis.cpp:42
Redis::set
bool set(const char *key, const char *value)
Definition: Redis.cpp:27
Redis::rpop
String rpop(const char *key)
Definition: Redis.cpp:602
Redis::lrem
int lrem(const char *key, int count, const char *element)
Definition: Redis.cpp:146
Redis::info
String info(const char *section)
Definition: Redis.cpp:597
Redis::hlen
int hlen(const char *key)
Definition: Redis.cpp:87
Redis::ltrim
bool ltrim(const char *key, int start, int stop)
Definition: Redis.cpp:156
Redis::xread
std::vector< String > xread(unsigned int count, unsigned int block, const char *key, const char *id)
Definition: Redis.cpp:461
Redis::xrevrange
std::vector< String > xrevrange(const char *key, const char *end, const char *start, unsigned int count)
Definition: Redis.cpp:547