mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-18 20:24:04 +01:00
Add flush method
This commit is contained in:
parent
180cd8963b
commit
f54a25f041
@ -96,7 +96,7 @@ public:
|
|||||||
/// Disconnects from the Redis server.
|
/// Disconnects from the Redis server.
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T execute(const Array& command, bool flush = true)
|
T execute(const Array& command)
|
||||||
/// Sends the Redis Command to the server. It gets the reply
|
/// Sends the Redis Command to the server. It gets the reply
|
||||||
/// and tries to convert it to the given template type.
|
/// and tries to convert it to the given template type.
|
||||||
/// A specialization exists for type void, which doesn't read
|
/// A specialization exists for type void, which doesn't read
|
||||||
@ -106,11 +106,6 @@ public:
|
|||||||
/// converted. Supported types are Int64, std::string, BulkString,
|
/// converted. Supported types are Int64, std::string, BulkString,
|
||||||
/// Array and void. When the reply is an Error, it will throw
|
/// Array and void. When the reply is an Error, it will throw
|
||||||
/// a RedisException.
|
/// a RedisException.
|
||||||
///
|
|
||||||
/// The flush argument only makes sense when using for type void.
|
|
||||||
/// When flush is false, the commands are build in a buffer and stays
|
|
||||||
/// there until flush is called or when a command is executed with
|
|
||||||
/// flush set to true.
|
|
||||||
{
|
{
|
||||||
T result;
|
T result;
|
||||||
writeCommand(command, true);
|
writeCommand(command, true);
|
||||||
@ -182,14 +177,14 @@ inline Net::SocketAddress Client::address() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<> inline
|
template<> inline
|
||||||
void Client::execute<void>(const Array& command, bool flush)
|
void Client::execute<void>(const Array& command)
|
||||||
{
|
{
|
||||||
writeCommand(command, flush);
|
writeCommand(command, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Client::flush()
|
inline void Client::flush()
|
||||||
{
|
{
|
||||||
poco_assert(!_output);
|
poco_assert(_output);
|
||||||
_output->flush();
|
_output->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -700,6 +700,7 @@ void RedisTest::testPipeliningWithWriteCommand()
|
|||||||
|
|
||||||
_redis.execute<void>(ping);
|
_redis.execute<void>(ping);
|
||||||
_redis.execute<void>(ping);
|
_redis.execute<void>(ping);
|
||||||
|
_redis.flush();
|
||||||
|
|
||||||
// We expect 2 results with simple "PONG" strings
|
// We expect 2 results with simple "PONG" strings
|
||||||
for(int i = 0; i < 2; ++i)
|
for(int i = 0; i < 2; ++i)
|
||||||
@ -743,6 +744,7 @@ void RedisTest::testPubSub()
|
|||||||
.add("test");
|
.add("test");
|
||||||
|
|
||||||
_redis.execute<void>(subscribe);
|
_redis.execute<void>(subscribe);
|
||||||
|
_redis.flush();
|
||||||
|
|
||||||
AsyncReader reader(_redis);
|
AsyncReader reader(_redis);
|
||||||
reader.redisResponse += Poco::delegate(&subscriber, &RedisSubscriber::onMessage);
|
reader.redisResponse += Poco::delegate(&subscriber, &RedisSubscriber::onMessage);
|
||||||
@ -754,6 +756,7 @@ void RedisTest::testPubSub()
|
|||||||
unsubscribe.add("UNSUBSCRIBE");
|
unsubscribe.add("UNSUBSCRIBE");
|
||||||
|
|
||||||
_redis.execute<void>(unsubscribe);
|
_redis.execute<void>(unsubscribe);
|
||||||
|
_redis.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
CppUnit::Test* RedisTest::suite()
|
CppUnit::Test* RedisTest::suite()
|
||||||
|
Loading…
Reference in New Issue
Block a user