Skip to content

Commit

Permalink
Inlined some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kürzeder committed Jul 27, 2019
1 parent 238fba9 commit 7571810
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 35 deletions.
30 changes: 0 additions & 30 deletions module/RedisClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,6 @@ redis_client::~redis_client()
delete _subscriber;
}

void redis_client::connect(const std::string& host, const int& port) const
{
_client->connect(host, port);
_subscriber->connect(host, port);
}

void redis_client::disconnect() const
{
_client->disconnect(true);
_subscriber->disconnect(true);
}

bool redis_client::is_connected() const
{
return _client->is_connected() && _subscriber->is_connected();
}

cpp_redis::reply redis_client::set(const std::string& key, const std::string& value) const
{
auto result = _client->set(key, value);
Expand All @@ -43,13 +26,6 @@ cpp_redis::reply redis_client::set(const std::string& key, const std::string& va
return result.get();
}

void redis_client::set(const std::string& key, const std::string& value,
const cpp_redis::client::reply_callback_t& callback) const
{
_client->set(key, value, callback);
_client->commit();
}

void redis_client::set(const std::map<std::string, std::string>& pairs, const std::function<void(const std::string&, cpp_redis::reply &)>& callback) const
{
for(auto& [key, value]: pairs)
Expand All @@ -71,12 +47,6 @@ cpp_redis::reply redis_client::get(const std::string& key) const
return result.get();
}

void redis_client::get(const std::string& key, const cpp_redis::client::reply_callback_t& callback) const
{
_client->get(key, callback);
_client->commit();
}

void redis_client::get(const std::list<std::string>& keys, const std::function<void(const std::string&, cpp_redis::reply &)>& callback) const
{
for (auto& key : keys)
Expand Down
10 changes: 5 additions & 5 deletions module/RedisClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ class redis_client
redis_client();
~redis_client();

void connect(const std::string& host, const int& port) const;
void disconnect() const;
[[nodiscard]] bool is_connected() const;
void connect(const std::string& host, const int& port) const { _client->connect(host, port); _subscriber->connect(host, port); }
void disconnect() const { _client->disconnect(); _subscriber->disconnect(); }
[[nodiscard]] bool is_connected() const { return _client->is_connected() && _subscriber->is_connected(); }

[[nodiscard]] cpp_redis::reply set(const std::string& key, const std::string& value) const;
void set(const std::string& key, const std::string& value, const cpp_redis::client::reply_callback_t& callback) const;
void set(const std::string& key, const std::string& value, const cpp_redis::client::reply_callback_t& callback) const { _client->set(key, value, callback); _client->commit(); }
void set(const std::map<std::string, std::string>& pairs, const std::function<void(const std::string&, cpp_redis::reply &)>& callback) const;

[[nodiscard]] cpp_redis::reply get(const std::string& key) const;
void get(const std::string& key, const cpp_redis::client::reply_callback_t& callback) const;
void get(const std::string& key, const cpp_redis::client::reply_callback_t& callback) const { _client->get(key, callback); _client->commit(); };
void get(const std::list<std::string>& keys, const std::function<void(const std::string&, cpp_redis::reply &)>& callback) const;
private:
cpp_redis::client* _client;
Expand Down

0 comments on commit 7571810

Please sign in to comment.