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, String) |
typedef void(* | RedisMsgErrorCallback) (Redis *, RedisMessageError) |
Public Member Functions | |
Redis (Client &client) | |
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 | ttl (const char *key) |
int | pttl (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) |
std::vector< String > | lrange (const char *key, int start, int stop) |
bool | subscribe (const char *channel) |
bool | psubscribe (const char *pattern) |
bool | unsubscribe (const char *channelOrPattern) |
RedisSubscribeResult | startSubscribing (RedisMsgCallback messageCallback, RedisMsgErrorCallback errorCallback=nullptr) |
void | stopSubscribing () |
#include <Redis.h>
|
inline |
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 | ) |
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 | ||
) |
int Redis::hlen | ( | const char * | key | ) |
|
inline |
|
inline |
int Redis::hstrlen | ( | const char * | key, |
const char * | field | ||
) |
std::vector< String > Redis::lrange | ( | const char * | key, |
int | start, | ||
int | stop | ||
) |
Returns the specified elements of the list stored at key
.
start | Zero-based starting index (can be negative to indicate end-of-list offset). |
end | Zero-based ending index. |
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 | ||
) |
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 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. |
|
inline |
|
inline |
|
inline |