Arduino-Redis
A Redis library for Arduino.
|
Redis-for-Arduino client interface.
The sole constructor takes a reference to any instance of a Client subclass, allowing it to be used with any library that abstracts the client bytestream in this way (such as the built-in Ethernet class or the WiFiClient for devices such as the ESP8266).
Public Types | |
typedef void(* | RedisMsgCallback) (Redis *, String channel, String message) |
typedef void(* | LoopCallback) () |
typedef void(* | RedisMsgErrorCallback) (Redis *, RedisMessageError) |
Public Member Functions | |
Redis (Client &client) | |
~Redis () | |
Redis (const Redis &)=delete | |
Redis & | operator= (const Redis &)=delete |
Redis (const Redis &&)=delete | |
Redis & | operator= (const Redis &&)=delete |
RedisReturnValue | authenticate (const char *password) |
bool | set (const char *key, const char *value) |
String | get (const char *key) |
bool | del (const char *key) |
bool | exists (const char *key) |
int | append (const char *key, const char *value) |
int | publish (const char *channel, const char *message) |
bool | expire (const char *key, int seconds) |
bool | expire_at (const char *key, int timestamp) |
bool | pexpire (const char *key, int ms) |
bool | pexpire_at (const char *key, int timestamp) |
bool | persist (const char *key) |
int | pttl (const char *key) |
int | ttl (const char *key) |
bool | hset (const char *key, const char *field, const char *value) |
bool | hsetnx (const char *key, const char *field, const char *value) |
String | hget (const char *key, const char *field) |
bool | hdel (const char *key, const char *field) |
int | hlen (const char *key) |
int | hstrlen (const char *key, const char *field) |
bool | hexists (const char *key, const char *field) |
String | lindex (const char *key, int index) |
int | llen (const char *key) |
String | lpop (const char *key) |
int | lpos (const char *key, const char *element) |
int | lpush (const char *key, const char *value, bool exclusive=false) |
std::vector< String > | lrange (const char *key, int start, int stop) |
int | lrem (const char *key, int count, const char *element) |
bool | lset (const char *key, int index, const char *element) |
bool | ltrim (const char *key, int start, int stop) |
String | rpop (const char *key) |
int | rpush (const char *key, const char *value, bool exclusive=false) |
bool | subscribe (const char *channel) |
bool | psubscribe (const char *pattern) |
bool | unsubscribe (const char *channelOrPattern) |
bool | tsadd (const char *key, long timestamp, const int value) |
int | xack (const char *key, const char *group, const char *id) |
String | xadd (const char *key, const char *id, const char *field, const char *value) |
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) |
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) |
int | xdel (const char *key, const char *id) |
bool | xgroup_create (const char *key, const char *group, const char *id, bool mkstream) |
int | xgroup_createconsumer (const char *key, const char *group, const char *consumer) |
int | xgroup_delconsumer (const char *key, const char *group, const char *consumer) |
int | xgroup_destroy (const char *key, const char *group) |
bool | xgroup_setid (const char *key, const char *group, const char *id) |
std::vector< String > | xinfo_consumers (const char *key, const char *group) |
std::vector< String > | xinfo_groups (const char *key) |
std::vector< String > | xinfo_stream (const char *key, bool full, unsigned int count) |
int | xlen (const char *key) |
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) |
std::vector< String > | xrange (const char *key, const char *start, const char *end, unsigned int count) |
std::vector< String > | xread (unsigned int count, unsigned int block, const char *key, const char *id) |
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) |
std::vector< String > | xrevrange (const char *key, const char *end, const char *start, unsigned int count) |
int | xtrim (const char *key, const char *strategy, XtrimCompareType compare, int threshold, int count) |
bool | isErrorReturn (std::vector< String > &returnVec) |
bool | isNilReturn (String returnString) |
RedisSubscribeResult | startSubscribing (RedisMsgCallback messageCallback, RedisMsgErrorCallback errorCallback=nullptr) |
RedisSubscribeResult | startSubscribingNonBlocking (RedisMsgCallback messageCallback, LoopCallback loopCallback, RedisMsgErrorCallback errorCallback=nullptr) |
void | stopSubscribing () |
String | info (const char *section) |
void | setTestContext (const void *context) |
const void * | getTestContext () |
#include <Redis.h>
typedef void(* Redis::RedisMsgCallback) (Redis *, String channel, String message) |
typedef void(* Redis::RedisMsgErrorCallback) (Redis *, RedisMessageError) |
|
inline |
|
delete |
|
delete |
int Redis::append | ( | const char * | key, |
const char * | value | ||
) |
RedisReturnValue Redis::authenticate | ( | const char * | password | ) |
bool Redis::del | ( | const char * | key | ) |
bool Redis::exists | ( | const char * | key | ) |
|
inline |
|
inline |
Expire a key
at UNIX timestamp timestamp
(seconds since January 1, 1970).
key | The key name for which to set expire time. |
timestamp | The UNIX timestamp at which this key will expire. |
true
if the expire time was set successfully, false
otherwise. String Redis::get | ( | const char * | key | ) |
Get key
.
key | The key name to retrieve. |
isNilReturn()
to check for the latter in a future-proof way. bool Redis::hdel | ( | const char * | key, |
const char * | field | ||
) |
bool Redis::hexists | ( | const char * | key, |
const char * | field | ||
) |
String Redis::hget | ( | const char * | key, |
const char * | field | ||
) |
Gets field
stored in hash at key
.
key | |
field |
isNilReturn()
to check for the latter in a future-proof way. int Redis::hlen | ( | const char * | key | ) |
|
inline |
|
inline |
int Redis::hstrlen | ( | const char * | key, |
const char * | field | ||
) |
bool Redis::isErrorReturn | ( | std::vector< String > & | returnVec | ) |
|
inline |
String Redis::lindex | ( | const char * | key, |
int | index | ||
) |
Returns the element of the list stored at index
.
key | |
end | Zero-based element index. |
isNilReturn()
to check for the latter in a future-proof way. int Redis::llen | ( | const char * | key | ) |
String Redis::lpop | ( | const char * | key | ) |
Removes and returns the first element of the list stored at key
.
key |
isNilReturn()
to check for the latter in a future-proof way. int Redis::lpos | ( | const char * | key, |
const char * | element | ||
) |
int Redis::lpush | ( | const char * | key, |
const char * | value, | ||
bool | exclusive = false |
||
) |
Insert the specified value
at the head of the list stored at key
(or 'LPUSHX' semantics if exclusive
is true)
key | |
value | |
exclusive | If set, issues 'LPUSHX' instead of 'LPUSH' which pushes value only if key already exists and holds a list. In contrary to LPUSH, no operation will be performed when key does not yet exist. |
std::vector< String > Redis::lrange | ( | const char * | key, |
int | start, | ||
int | stop | ||
) |
Returns the specified elements of the list stored at key
.
key | |
start | Zero-based starting index (can be negative to indicate end-of-list offset). |
end | Zero-based ending index. |
int Redis::lrem | ( | const char * | key, |
int | count, | ||
const char * | element | ||
) |
Removes the first count
occurrences of elements equal to element
from the list stored at key
.
key | |
count | if less than zero: removes elements moving from head to tail; if greater than zero, removes from tail to head. if zero, removes all. |
element |
bool Redis::lset | ( | const char * | key, |
int | index, | ||
const char * | element | ||
) |
bool Redis::ltrim | ( | const char * | key, |
int | start, | ||
int | stop | ||
) |
bool Redis::persist | ( | const char * | key | ) |
|
inline |
|
inline |
Expire a key
at UNIX timestamp timestamp
(milliseconds since January 1, 1970).
key | The key name for which to set expire time. |
timestamp | The UNIX timestamp at which this key will expire. |
true
if the expire time was set successfully, false
otherwise.
|
inline |
|
inline |
int Redis::publish | ( | const char * | channel, |
const char * | message | ||
) |
String Redis::rpop | ( | const char * | key | ) |
Removes and returns the last element of the list stored at key
.
key |
isNilReturn()
to check for the latter in a future-proof way. int Redis::rpush | ( | const char * | key, |
const char * | value, | ||
bool | exclusive = false |
||
) |
Insert the specified value
at the tail of the list stored at key
(or 'RPUSHX' semantics if exclusive
is true)
key | |
value | |
exclusive | If set, issues 'RPUSHX' instead of 'RPUSH' which pushes value only if key already exists and holds a list. In contrary to RPUSH, no operation will be performed when key does not yet exist. |
bool Redis::set | ( | const char * | key, |
const char * | value | ||
) |
Set key
to value
.
key | The key name to set |
value | The value to set for key |
true
if key
was set to value
, false if error. RedisSubscribeResult Redis::startSubscribing | ( | RedisMsgCallback | messageCallback, |
RedisMsgErrorCallback | errorCallback = nullptr |
||
) |
Enters subscription mode and subscribes to all channels/patterns setup via subscribe()
/psubscribe()
. On success, this call will block until stopSubscribing() is called (meaning loop()
will never be called!), and only then will return RedisSubscribeSuccess
. On remote disconnect, this call will end with the return value RedisSubscribeServerDisconnected
, which is generally non-fatal. On failure, this call will return immediately with a return value indicated the failure mode. Calling stopSubscribing()
will force this method to exit on the next recieved message.
messageCallback | The function to be called on each successful message receipt. |
errorCallback | The function to be called if message receipt processing produces an error. Call stopSubscribing() on the passed-in instance to end all further message processing. |
RedisSubscribeResult Redis::startSubscribingNonBlocking | ( | RedisMsgCallback | messageCallback, |
LoopCallback | loopCallback, | ||
RedisMsgErrorCallback | errorCallback = nullptr |
||
) |
|
inline |
|
inline |
bool Redis::tsadd | ( | const char * | key, |
long | timestamp, | ||
const int | value | ||
) |
Append a sample to a time series. If the time series does not exist, it will be automatically created.
key | Key name for time series. |
timestamp | UNIX sample timestamp in milliseconds. Any negative value given for this parameter will request an automatic timestamp from the system clock. |
value | Numeric data value of the sample. |
|
inline |
bool Redis::unsubscribe | ( | const char * | channelOrPattern | ) |
int Redis::xack | ( | const char * | key, |
const char * | group, | ||
const char * | id | ||
) |
String Redis::xadd | ( | const char * | key, |
const char * | id, | ||
const char * | field, | ||
const char * | value | ||
) |
std::vector< String > Redis::xautoclaim | ( | const char * | key, |
const char * | group, | ||
const char * | consumer, | ||
unsigned int | min_idle_time, | ||
const char * | start, | ||
unsigned int | count, | ||
bool | justid | ||
) |
std::vector< String > Redis::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 | ||
) |
int Redis::xdel | ( | const char * | key, |
const char * | id | ||
) |
bool Redis::xgroup_create | ( | const char * | key, |
const char * | group, | ||
const char * | id, | ||
bool | mkstream | ||
) |
int Redis::xgroup_createconsumer | ( | const char * | key, |
const char * | group, | ||
const char * | consumer | ||
) |
int Redis::xgroup_delconsumer | ( | const char * | key, |
const char * | group, | ||
const char * | consumer | ||
) |
int Redis::xgroup_destroy | ( | const char * | key, |
const char * | group | ||
) |
bool Redis::xgroup_setid | ( | const char * | key, |
const char * | group, | ||
const char * | id | ||
) |
std::vector< String > Redis::xinfo_consumers | ( | const char * | key, |
const char * | group | ||
) |
std::vector< String > Redis::xinfo_groups | ( | const char * | key | ) |
std::vector< String > Redis::xinfo_stream | ( | const char * | key, |
bool | full, | ||
unsigned int | count | ||
) |
int Redis::xlen | ( | const char * | key | ) |
std::vector< String > Redis::xpending | ( | const char * | key, |
const char * | group, | ||
unsigned int | min_idle_time, | ||
const char * | start, | ||
const char * | end, | ||
unsigned int | count, | ||
const char * | consumer | ||
) |
std::vector< String > Redis::xrange | ( | const char * | key, |
const char * | start, | ||
const char * | end, | ||
unsigned int | count | ||
) |
std::vector< String > Redis::xread | ( | unsigned int | count, |
unsigned int | block, | ||
const char * | key, | ||
const char * | id | ||
) |
std::vector< String > Redis::xreadgroup | ( | const char * | group, |
const char * | consumer, | ||
unsigned int | count, | ||
unsigned int | block_ms, | ||
bool | noack, | ||
const char * | key, | ||
const char * | id | ||
) |
std::vector< String > Redis::xrevrange | ( | const char * | key, |
const char * | end, | ||
const char * | start, | ||
unsigned int | count | ||
) |
int Redis::xtrim | ( | const char * | key, |
const char * | strategy, | ||
XtrimCompareType | compare, | ||
int | threshold, | ||
int | count | ||
) |