mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 19:10:20 +01:00
Add password field for Redis Client (#1838)
* Add password field for Redis Client * Revert change for constructor and add property for authenticated result * Correct createObject when no password * Fix compile problem and add type check before return object * Remove password property in Redis pool factory * Remove validate for no password case * Correct return value for empty password
This commit is contained in:
committed by
Aleksandar Fabijanic
parent
6714322122
commit
0aec1e162f
@@ -115,6 +115,12 @@ public:
|
||||
void connect(const Net::SocketAddress& addrs, const Timespan& timeout);
|
||||
/// Connects to the given Redis server.
|
||||
|
||||
bool sendAuth(const std::string& password);
|
||||
/// Sends password to Redis server
|
||||
|
||||
bool isAuthenticated();
|
||||
/// Returns true when the client is authenticated
|
||||
|
||||
void disconnect();
|
||||
/// Disconnects from the Redis server.
|
||||
|
||||
@@ -198,6 +204,7 @@ private:
|
||||
Net::StreamSocket _socket;
|
||||
RedisInputStream* _input;
|
||||
RedisOutputStream* _output;
|
||||
bool _authenticated;
|
||||
};
|
||||
|
||||
|
||||
@@ -231,6 +238,10 @@ inline void Client::setReceiveTimeout(const Timespan& timeout)
|
||||
_socket.setReceiveTimeout(timeout);
|
||||
}
|
||||
|
||||
inline bool Client::isAuthenticated()
|
||||
{
|
||||
return _authenticated;
|
||||
}
|
||||
|
||||
} } // namespace Poco::Redis
|
||||
|
||||
|
||||
@@ -35,23 +35,23 @@ class PoolableObjectFactory<Redis::Client, Redis::Client::Ptr>
|
||||
{
|
||||
public:
|
||||
PoolableObjectFactory(Net::SocketAddress& address):
|
||||
_address(address)
|
||||
_address(address)
|
||||
{
|
||||
}
|
||||
|
||||
PoolableObjectFactory(const std::string& address):
|
||||
_address(address)
|
||||
_address(address)
|
||||
{
|
||||
}
|
||||
|
||||
Redis::Client::Ptr createObject()
|
||||
{
|
||||
return new Redis::Client(_address);
|
||||
return new Redis::Client(_address);
|
||||
}
|
||||
|
||||
bool validateObject(Redis::Client::Ptr pObject)
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void activateObject(Redis::Client::Ptr pObject)
|
||||
@@ -91,7 +91,10 @@ public:
|
||||
{
|
||||
try
|
||||
{
|
||||
_pool.returnObject(_client);
|
||||
if (_client)
|
||||
{
|
||||
_pool.returnObject(_client);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user