ctrl-utils
|
Public Member Functions | |
void | connect (const std::string &host="127.0.0.1", size_t port=6379, const std::string &password="") |
template<typename T > | |
std::future< T > | get (const std::string &key) |
template<typename T > | |
std::future< void > | get (const std::string &key, T &val) |
template<typename T > | |
RedisClient & | get (const std::string &key, const std::function< void(T &&)> &reply_callback, const std::function< void(const std::string &)> &error_callback={}) |
template<typename T > | |
T | sync_get (const std::string &key) |
template<typename T > | |
std::future< cpp_redis::reply > | set (const std::string &key, const T &value) |
template<typename T > | |
RedisClient & | set (const std::string &key, const T &value, const reply_callback_t &reply_callback) |
template<typename T > | |
cpp_redis::reply | sync_set (const std::string &key, const T &value) |
template<class... Ts, class... Strings, typename = is_all_strings<Strings...>> | |
std::future< std::tuple< Ts... > > | mget (const Strings &... keys) |
template<typename T > | |
std::future< std::vector< T > > | mget (const std::vector< std::string > &keys) |
template<class... Ts, class... Strings, typename = is_all_strings<Strings...>> | |
std::tuple< Ts... > | sync_mget (const Strings &... keys) |
template<typename T > | |
std::vector< T > | sync_mget (const std::vector< std::string > &keys) |
template<class... Pairs, typename = is_all_pairs<Pairs...>> | |
std::future< cpp_redis::reply > | mset (const Pairs &... key_vals) |
template<typename T > | |
std::future< cpp_redis::reply > | mset (const std::vector< std::pair< std::string, T >> &key_vals) |
template<typename T > | |
RedisClient & | mset (const std::vector< std::pair< std::string, T >> &key_vals, const reply_callback_t &reply_callback) |
template<class... Pairs, typename = is_all_pairs<Pairs...>> | |
cpp_redis::reply | sync_mset (const Pairs &... key_vals) |
template<typename T > | |
cpp_redis::reply | sync_mset (const std::vector< std::pair< std::string, T >> &key_vals) |
template<typename T > | |
RedisClient & | hset (const std::string &key, const std::string &field, const T &value, const reply_callback_t &reply_callback) |
template<typename T > | |
std::future< cpp_redis::reply > | hset (const std::string &key, const std::string &field, const T &value) |
template<typename T > | |
cpp_redis::reply | sync_hset (const std::string &key, const std::string &field, const T &value) |
template<typename T > | |
RedisClient & | publish (const std::string &key, const T &value, const reply_callback_t &reply_callback) |
template<typename T > | |
std::future< cpp_redis::reply > | publish (const std::string &key, const T &value) |
template<typename T > | |
cpp_redis::reply | sync_publish (const std::string &key, const T &value) |
template<typename TSub , typename TPub > | |
RedisClient & | request (const std::string &key_pub, const TPub &value_pub, const std::string &key_sub, std::function< void(TSub &&)> &&sub_callback) |
template<typename TSub , typename TPub > | |
std::future< TSub > | request (const std::string &key_pub, const TPub &value_pub, const std::string &key_sub) |
template<typename TSub , typename TPub > | |
TSub | sync_request (const std::string &key_pub, const TPub &value_pub, const std::string &key_sub) |
RedisClient & | scan (const std::string &pattern, std::function< void(std::unordered_set< std::string > &&)> &&callback) |
std::future< std::unordered_set< std::string > > | scan (const std::string &pattern) |
std::unordered_set< std::string > | sync_scan (const std::string &pattern) |
template<class... Ts, class... Args, typename > | |
std::tuple< Ts... > | sync_mget (const Args &... args) |
std::future< T > ctrl_utils::RedisClient::get | ( | const std::string & | key | ) |
Asynchronous Redis GET command with std::future.
Values will get converted from strings with ctrl_utils::FromString<T>(), or if a specialization for that type doesn't exist, std::stringstream::operator>>(). These specializations can be defined locally for custom types in your code.
Commands are not sent until RedisClient::commit() is called.
Example
key | Redis key. |
RedisClient & ctrl_utils::RedisClient::get | ( | const std::string & | key, |
const std::function< void(T &&)> & | reply_callback, | ||
const std::function< void(const std::string &)> & | error_callback = {} |
||
) |
Asynchronous Redis GET command with callbacks.
Values will get converted from strings with ctrl_utils::FromString<T>(), or if a specialization for that type doesn't exist, std::stringstream::operator>>(). These specializations can be defined locally for custom types in your code.
Commands are not sent until RedisClient::commit() is called.
Example
key | Redis key. |
reply_callback | Callback function that gets the value result passed in as an Rvalue reference the command has finished. |
error_callback | Callback function that gets called with the error string when the command has failed. |
std::future< void > ctrl_utils::RedisClient::get | ( | const std::string & | key, |
T & | val | ||
) |
Asynchronous Redis GET command with preallocated value.
Values will get converted from strings with ctrl_utils::FromString<T>(), or if a specialization for that type doesn't exist, std::stringstream::operator>>(). These specializations can be defined locally for custom types in your code.
Commands are not sent until RedisClient::commit() is called.
Example
key | Redis key. |
std::future< std::vector< T > > ctrl_utils::RedisClient::mget | ( | const std::vector< std::string > & | keys | ) |
Asynchronous Redis MGET command with std::future for homogeneous value types.
Commands are not sent until RedisClient::commit() is called.
Example
key_vals | Vector of key-value pairs. |
std::future< std::tuple< Ts... > > ctrl_utils::RedisClient::mget | ( | const Strings &... | keys | ) |
Asynchronous Redis MGET command with std::future for heterogeneous value types.
Commands are not sent until RedisClient::commit() is called.
Example
key_vals | Vector of key-value pairs. |
std::future< cpp_redis::reply > ctrl_utils::RedisClient::mset | ( | const Pairs &... | key_vals | ) |
Asynchronous Redis MSET command with std::future for heterogeneous value types.
Commands are not sent until RedisClient::commit() is called.
Example
key_vals | Vector of key-value pairs. |
std::future< cpp_redis::reply > ctrl_utils::RedisClient::mset | ( | const std::vector< std::pair< std::string, T >> & | key_vals | ) |
Asynchronous Redis MSET command with std::future for homogeneous value types.
Commands are not sent until RedisClient::commit() is called.
Example
key_vals | Vector of key-value pairs. |
RedisClient & ctrl_utils::RedisClient::mset | ( | const std::vector< std::pair< std::string, T >> & | key_vals, |
const reply_callback_t & | reply_callback | ||
) |
Asynchronous Redis MSET command with callbacks.
Commands are not sent until RedisClient::commit() is called.
Example
key_vals | Vector of key-value pairs. |
reply_callback | Callback function of type std::function<void(cpp_redis::reply&)> that gets called when the command has finished. |
std::future< cpp_redis::reply > ctrl_utils::RedisClient::set | ( | const std::string & | key, |
const T & | value | ||
) |
Asynchronous Redis SET command with std::future.
Values will get converted to strings with ctrl_utils::ToString<T>(), or if a specialization for that type doesn't exist, std::stringstream::operator<<(). These specializations can be defined locally for custom types in your code.
Commands are not sent until RedisClient::commit() is called.
Example
key | Redis key. |
value | Redis value. |
RedisClient & ctrl_utils::RedisClient::set | ( | const std::string & | key, |
const T & | value, | ||
const reply_callback_t & | reply_callback | ||
) |
Asynchronous Redis SET command with callbacks.
Values will get converted to strings with ctrl_utils::ToString<T>(), or if a specialization for that type doesn't exist, std::stringstream::operator<<(). These specializations can be defined locally for custom types in your code.
Commands are not sent until RedisClient::commit() is called.
Example
key | Redis key. |
value | Redis value. |
reply_callback | Callback function of type std::function<void(cpp_redis::reply&)> that gets called when the command has finished. |
T ctrl_utils::RedisClient::sync_get | ( | const std::string & | key | ) |
Synchronous Redis GET command with std::future.
Values will get converted from strings with ctrl_utils::FromString<T>(), or if a specialization for that type doesn't exist, std::stringstream::operator>>(). These specializations can be defined locally for custom types in your code.
Example
key | Redis key. |
std::vector< T > ctrl_utils::RedisClient::sync_mget | ( | const std::vector< std::string > & | keys | ) |
Synchronous Redis MGET command for a vector of a single type.
Example
key_vals | Vector of key-value pairs. |
std::tuple<Ts...> ctrl_utils::RedisClient::sync_mget | ( | const Strings &... | keys | ) |
Synchronous Redis MGET command.
Example
key_vals | Vector of key-value pairs. |
cpp_redis::reply ctrl_utils::RedisClient::sync_mset | ( | const Pairs &... | key_vals | ) |
Synchronous Redis MSET command for heterogeneous value types.
Example
key_vals | Vector of key-value pairs. |
cpp_redis::reply ctrl_utils::RedisClient::sync_mset | ( | const std::vector< std::pair< std::string, T >> & | key_vals | ) |
Synchronous Redis MSET command for homogeneous value types.
Example
key_vals | Vector of key-value pairs. |
cpp_redis::reply ctrl_utils::RedisClient::sync_set | ( | const std::string & | key, |
const T & | value | ||
) |
Synchronous Redis SET command.
Values will get converted to strings with ctrl_utils::ToString<T>(), or if a specialization for that type doesn't exist, std::stringstream::operator<<(). These specializations can be defined locally for custom types in your code.
Example
key | Redis key. |
value | Redis value. |