-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stefan Kürzeder
committed
Jul 27, 2019
1 parent
cc7384e
commit 69aa470
Showing
4 changed files
with
67 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "RedisClient.h" | ||
#include "Module.h" | ||
|
||
RedisClient::RedisClient() | ||
{ | ||
_client = new redis_client(); | ||
_subscriber = new redis_subscriber(); | ||
|
||
g_Module->AddRedisClient(this); | ||
} | ||
|
||
RedisClient::~RedisClient() | ||
{ | ||
g_Module->RemoveRedisClient(this); | ||
|
||
delete _client; | ||
delete _subscriber; | ||
} | ||
|
||
void RedisClient::connect(const std::string& host, const int& port) const | ||
{ | ||
_client->connect(host, port); | ||
_subscriber->connect(host, port); | ||
} | ||
|
||
void RedisClient::disconnect() const | ||
{ | ||
_client->disconnect(true); | ||
_subscriber->disconnect(true); | ||
} | ||
|
||
bool RedisClient::is_connected() const | ||
{ | ||
return _client->is_connected() && _subscriber->is_connected(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
#include <cpp_redis/core/client.hpp> | ||
#include <cpp_redis/core/subscriber.hpp> | ||
|
||
using redis_client = cpp_redis::client; | ||
using redis_subscriber = cpp_redis::subscriber; | ||
|
||
class RedisClient | ||
{ | ||
public: | ||
RedisClient(); | ||
~RedisClient(); | ||
|
||
void connect(const std::string& host, const int& port) const; | ||
void disconnect() const; | ||
bool is_connected() const; | ||
private: | ||
redis_client* _client; | ||
redis_subscriber* _subscriber; | ||
}; | ||
|