Thunderbots Project
Loading...
Searching...
No Matches
RedisClient Class Reference

Public Member Functions

 RedisClient (std::string address, size_t port)
 
std::string getSync (const std::string &key)
 
void getAsync (const std::string &key, const cpp_redis::reply_callback_t &reply_callback)
 
void getAsyncNoCommit (const std::string &key, const cpp_redis::reply_callback_t &reply_callback)
 
void setAsync (const std::string &key, const std::string &value)
 
void setSync (const std::string &key, const std::string &value)
 
void setNoCommit (const std::string &key, const std::string &value)
 
void asyncCommit ()
 
void syncCommit ()
 
std::unordered_map< std::string, std::string > getAllKeyValuePairs ()
 

Constructor & Destructor Documentation

◆ RedisClient()

RedisClient ( std::string  address,
size_t  port 
)
explicit

Client that communicates with the a redis server

Parameters
addressThe IP of the Redis server, default localhost
portthe key of the Redis server, default 6379

Member Function Documentation

◆ asyncCommit()

void asyncCommit ( )

Asynchronously commit all pending requests since last commit.

◆ getAllKeyValuePairs()

std::unordered_map< std::string, std::string > getAllKeyValuePairs ( )
Returns
a map of all the key value pairs in redis server

◆ getAsync()

void getAsync ( const std::string &  key,
const cpp_redis::reply_callback_t &  reply_callback 
)

Gets the value corresponding to the key, non blocking - executes the callback once a reply is received.

Parameters
key
reply_callbackcallback function once the value is obtained

◆ getAsyncNoCommit()

void getAsyncNoCommit ( const std::string &  key,
const cpp_redis::reply_callback_t &  reply_callback 
)

Gets the value corresponding to the key, asynchronously but doesn't commit it. Must manually call asyncCommit() to commit it to the REDIS server.

Allows us to batch call a number of GET/SET requests to the REDIS server with one network request.

Parameters
key
reply_callbackcallback function once the value is obtained

◆ getSync()

std::string getSync ( const std::string &  key)

Gets the value corresponding to the key; blocking

Parameters
key
Returns
the value

◆ setAsync()

void setAsync ( const std::string &  key,
const std::string &  value 
)

Sets a key value pair in the redis database asynchronously

Parameters
key
value

◆ setNoCommit()

void setNoCommit ( const std::string &  key,
const std::string &  value 
)

Sets a key value pair in the redis database but does not commit it. Waits for the next commit() to send it to the REDIS server.

Allows us to batch call a number of GET/SET requests to the REDIS server with one network request.

Parameters
keykey for key-value pair
valuevalue to set to key-value pair

◆ setSync()

void setSync ( const std::string &  key,
const std::string &  value 
)

Gets the value corresponding to the key; blocking synchronously

Parameters
key
thevalue

◆ syncCommit()

void syncCommit ( )

Synchronously commit all pending requests since last commit.


The documentation for this class was generated from the following files: