style and documentation fixes

This commit is contained in:
Guenter Obiltschnig
2016-09-04 14:30:26 +02:00
parent fd9ca0a9b6
commit 64781d15f1
27 changed files with 791 additions and 487 deletions

View File

@@ -9,69 +9,74 @@
// //
// Definition of the Array class. // Definition of the Array class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#ifndef Redis_Array_INCLUDED #ifndef Redis_Array_INCLUDED
#define Redis_Array_INCLUDED #define Redis_Array_INCLUDED
#include <vector>
#include <sstream>
#include "Poco/Redis/Redis.h" #include "Poco/Redis/Redis.h"
#include "Poco/Redis/Type.h" #include "Poco/Redis/Type.h"
#include "Poco/Redis/Exception.h" #include "Poco/Redis/Exception.h"
#include <vector>
#include <sstream>
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
class Redis_API Array class Redis_API Array
/// Represents a Redis Array. An Array can contain Integers, Strings, /// Represents a Redis Array. An Array can contain Integers, Strings,
/// Bulk Strings, Errors and other arrays. It can also contain a Null /// Bulk Strings, Errors and other Arrays. It can also contain a Null
/// value. /// value.
{ {
public: public:
typedef std::vector<RedisType::Ptr>::const_iterator const_iterator; typedef std::vector<RedisType::Ptr>::const_iterator const_iterator;
Array(); Array();
/// Default constructor. As long as there are no elements added, /// Creates an Array. As long as there are no elements added,
/// the array will contain a Null value. /// the array will contain a Null value.
Array(const Array& copy); Array(const Array& copy);
/// Copy constructor. /// Creates an Array by copying another one.
virtual ~Array(); virtual ~Array();
/// Destructor. /// Destroys the Array.
template<typename T> template<typename T>
Array& operator<<(const T& arg) Array& operator<<(const T& arg)
/// Adds the argument to the array. /// Adds the argument to the array.
///
/// Note: a std::string will be added as a BulkString because this /// Note: a std::string will be added as a BulkString because this
/// is commonly used for representing strings in Redis. If you /// is commonly used for representing strings in Redis. If you
/// really need a simple string, use addSimpleString. /// really need a simple string, use addSimpleString().
{ {
return add(arg); return add(arg);
} }
Array& operator<<(const char* s); Array& operator<<(const char* s);
/// Special implementation for const char* /// Special implementation for const char*.
///
/// Note: the specialization creates a BulkString. If you need /// Note: the specialization creates a BulkString. If you need
/// a simple string, call addSimpleString. /// a simple string, call addSimpleString().
Array& operator<<(const std::vector<std::string>& strings); Array& operator<<(const std::vector<std::string>& strings);
/// Special implementation for a vector with strings /// Special implementation for a vector with strings.
/// All strings will be added as a BulkString. /// All strings will be added as a BulkString.
Array& add(); Array& add();
/// Adds an Null BulkString /// Adds an Null BulkString.
template<typename T> template<typename T>
Array& add(const T& arg) Array& add(const T& arg)
/// Adds an element to the array. /// Adds an element to the array.
///
/// Note: the specialization for std::string will add a BulkString! /// Note: the specialization for std::string will add a BulkString!
/// If you really need a simple string, call addSimpleString. /// If you really need a simple string, call addSimpleString.
{ {
@@ -80,38 +85,41 @@ public:
} }
Array& add(const char* s); Array& add(const char* s);
/// Special implementation for const char* /// Special implementation for const char*.
///
/// Note: the specialization creates a BulkString. If you need /// Note: the specialization creates a BulkString. If you need
/// a simple string, call addSimpleString. /// a simple string, call addSimpleString.
Array& add(const std::vector<std::string>& strings); Array& add(const std::vector<std::string>& strings);
/// Special implementation for a vector with strings /// Special implementation for a vector with strings.
/// All strings will be added as a BulkString. /// All strings will be added as a BulkString.
Array& addRedisType(RedisType::Ptr value); Array& addRedisType(RedisType::Ptr value);
/// Adds a Redis element. /// Adds a Redis element.
Array& addSimpleString(const std::string& value); Array& addSimpleString(const std::string& value);
/// Adds a simple string (can't contain newline characters!) /// Adds a simple string (can't contain newline characters!).
const_iterator begin() const; const_iterator begin() const;
/// Returns an iterator to the start of the array. Note: /// Returns an iterator to the start of the array.
/// this can throw a NullValueException when this is a Null array. ///
/// Note: this can throw a NullValueException when this is a Null array.
void clear(); void clear();
/// Removes all elements from the array. /// Removes all elements from the array.
const_iterator end() const; const_iterator end() const;
/// Returns an iterator to the end of the array. Note: /// Returns an iterator to the end of the array.
/// this can throw a NullValueException when this is a Null array. ///
/// Note: this can throw a NullValueException when this is a Null array.
template<typename T> template<typename T>
T get(size_t pos) const T get(size_t pos) const
/// Returns the element on the given position and tries to convert /// Returns the element on the given position and tries to convert
/// to the template type. A BadCastException will be thrown when the /// to the template type. A Poco::BadCastException will be thrown when the
/// the conversion fails. An InvalidArgumentException will be thrown /// the conversion fails. An Poco::InvalidArgumentException will be thrown
/// when the index is out of range. When the array is a Null array /// when the index is out of range. When the array is a Null array
/// a NullValueException is thrown. /// a Poco::NullValueException is thrown.
{ {
if ( _elements.isNull() ) throw NullValueException(); if ( _elements.isNull() ) throw NullValueException();
@@ -127,8 +135,8 @@ public:
} }
int getType(size_t pos) const; int getType(size_t pos) const;
/// Returns the type of the element. This can throw a NullValueException /// Returns the type of the element. This can throw a Poco::NullValueException
/// when this array is a Null array. An InvalidArgumentException will /// when this array is a Null array. An Poco::InvalidArgumentException will
/// be thrown when the index is out of range. /// be thrown when the index is out of range.
bool isNull() const; bool isNull() const;
@@ -143,34 +151,43 @@ public:
/// Redis Protocol specification. /// Redis Protocol specification.
size_t size() const; size_t size() const;
/// Returns the size of the array. Note: /// Returns the size of the array.
/// this can throw a NullValueException when this is a Null array. ///
/// Note: this can throw a NullValueException when this is a Null array.
private: private:
Nullable<std::vector<RedisType::Ptr> > _elements;
void checkNull(); void checkNull();
/// Checks for null array and sets a new vector if true. /// Checks for null array and sets a new vector if true.
Nullable<std::vector<RedisType::Ptr> > _elements;
}; };
//
// inlines
//
inline Array& Array::operator<<(const char* s) inline Array& Array::operator<<(const char* s)
{ {
BulkString value(s); BulkString value(s);
return add(value); return add(value);
} }
inline Array& Array::operator<<(const std::vector<std::string>& strings) inline Array& Array::operator<<(const std::vector<std::string>& strings)
{ {
return add(strings); return add(strings);
} }
inline Array& Array::add() inline Array& Array::add()
{ {
BulkString value; BulkString value;
return add(value); return add(value);
} }
template<> template<>
inline Array& Array::add(const std::string& arg) inline Array& Array::add(const std::string& arg)
{ {
@@ -178,12 +195,14 @@ inline Array& Array::add(const std::string& arg)
return add(value); return add(value);
} }
inline Array& Array::add(const char* s) inline Array& Array::add(const char* s)
{ {
BulkString value(s); BulkString value(s);
return add(value); return add(value);
} }
inline Array& Array::add(const std::vector<std::string>& strings) inline Array& Array::add(const std::vector<std::string>& strings)
{ {
for(std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); ++it) for(std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); ++it)
@@ -193,22 +212,26 @@ inline Array& Array::add(const std::vector<std::string>& strings)
return *this; return *this;
} }
inline Array& Array::addSimpleString(const std::string& value) inline Array& Array::addSimpleString(const std::string& value)
{ {
return addRedisType(new Type<std::string>(value)); return addRedisType(new Type<std::string>(value));
} }
inline Array::const_iterator Array::begin() const inline Array::const_iterator Array::begin() const
{ {
return _elements.value().begin(); return _elements.value().begin();
} }
inline void Array::checkNull() inline void Array::checkNull()
{ {
std::vector<RedisType::Ptr> v; std::vector<RedisType::Ptr> v;
if ( _elements.isNull() ) _elements.assign(v); if ( _elements.isNull() ) _elements.assign(v);
} }
inline void Array::clear() inline void Array::clear()
{ {
if ( !_elements.isNull() ) if ( !_elements.isNull() )
@@ -217,16 +240,19 @@ inline void Array::clear()
} }
} }
inline Array::const_iterator Array::end() const inline Array::const_iterator Array::end() const
{ {
return _elements.value().end(); return _elements.value().end();
} }
inline bool Array::isNull() const inline bool Array::isNull() const
{ {
return _elements.isNull(); return _elements.isNull();
} }
inline void Array::makeNull() inline void Array::makeNull()
{ {
if ( !_elements.isNull() ) _elements.value().clear(); if ( !_elements.isNull() ) _elements.value().clear();
@@ -234,6 +260,7 @@ inline void Array::makeNull()
_elements.clear(); _elements.clear();
} }
inline size_t Array::size() const inline size_t Array::size() const
{ {
return _elements.value().size(); return _elements.value().size();
@@ -291,6 +318,7 @@ struct RedisTypeTraits<Array>
}; };
}} } } // namespace Poco::Redis
#endif // Redis_Array_INCLUDED #endif // Redis_Array_INCLUDED

View File

@@ -9,7 +9,7 @@
// //
// Definition of the AsyncReader class. // Definition of the AsyncReader class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
@@ -25,6 +25,7 @@
#include "Poco/Redis/RedisEventArgs.h" #include "Poco/Redis/RedisEventArgs.h"
#include "Poco/Activity.h" #include "Poco/Activity.h"
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
@@ -37,17 +38,17 @@ class Redis_API AsyncReader
/// reading all replies. /// reading all replies.
{ {
public: public:
BasicEvent<RedisEventArgs> redisResponse; BasicEvent<RedisEventArgs> redisResponse;
/// Event that is called when a message is received /// Event that is fired when a message is received.
BasicEvent<RedisEventArgs> redisException; BasicEvent<RedisEventArgs> redisException;
/// Event that is called when an error occurred. /// Event that is fired when an error occurred.
AsyncReader(Client& client); AsyncReader(Client& client);
/// Constructor. /// Creates the AsyncReader using the given Client.
virtual ~AsyncReader(); virtual ~AsyncReader();
/// Destructor /// Destroys the AsyncReader.
bool isStopped(); bool isStopped();
/// Returns true if the activity is not running, false when it is. /// Returns true if the activity is not running, false when it is.
@@ -59,11 +60,9 @@ public:
/// Stops the read activity. /// Stops the read activity.
protected: protected:
void runActivity(); void runActivity();
private: private:
AsyncReader(const AsyncReader&); AsyncReader(const AsyncReader&);
AsyncReader& operator = (const AsyncReader&); AsyncReader& operator = (const AsyncReader&);
@@ -72,16 +71,23 @@ private:
}; };
//
// inlines
//
inline bool AsyncReader::isStopped() inline bool AsyncReader::isStopped()
{ {
return _activity.isStopped(); return _activity.isStopped();
} }
inline void AsyncReader::start() inline void AsyncReader::start()
{ {
_activity.start(); _activity.start();
} }
inline void AsyncReader::stop() inline void AsyncReader::stop()
{ {
_activity.stop(); _activity.stop();
@@ -90,4 +96,5 @@ inline void AsyncReader::stop()
} } // namespace Poco::Redis } } // namespace Poco::Redis
#endif //Redis_AsyncReader_INCLUDED #endif //Redis_AsyncReader_INCLUDED

View File

@@ -9,7 +9,7 @@
// //
// Definition of the Client class. // Definition of the Client class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
@@ -19,13 +19,14 @@
#ifndef Redis_Client_INCLUDED #ifndef Redis_Client_INCLUDED
#define Redis_Client_INCLUDED #define Redis_Client_INCLUDED
#include "Poco/Net/SocketAddress.h"
#include "Poco/Timespan.h"
#include "Poco/Redis/Redis.h" #include "Poco/Redis/Redis.h"
#include "Poco/Redis/Array.h" #include "Poco/Redis/Array.h"
#include "Poco/Redis/Error.h" #include "Poco/Redis/Error.h"
#include "Poco/Redis/RedisStream.h" #include "Poco/Redis/RedisStream.h"
#include "Poco/Net/SocketAddress.h"
#include "Poco/Timespan.h"
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
@@ -56,28 +57,27 @@ class Redis_API Client
/// ///
/// Command llen = Command::llen("list"); /// Command llen = Command::llen("list");
/// ///
/// is the same as /// is the same as:
/// ///
/// Array command; /// Array command;
/// command.add("LLEN").add("list"); /// command.add("LLEN").add("list");
/// ///
/// or /// or:
/// ///
/// Array command; /// Array command;
/// command << "LLEN" << "list"; /// command << "LLEN" << "list";
/// ///
/// or even /// or even:
/// ///
/// Command command("LLEN"); /// Command command("LLEN");
/// command << "list"; /// command << "list";
{ {
public: public:
typedef SharedPtr<Client> Ptr; typedef SharedPtr<Client> Ptr;
Client(); Client();
/// Default constructor. Use this when you want to /// Creates an unconnected Client.
/// connect later on. /// Use this when you want to connect later on.
Client(const std::string& hostAndPort); Client(const std::string& hostAndPort);
/// Constructor which connects to the given Redis host/port. /// Constructor which connects to the given Redis host/port.
@@ -90,7 +90,7 @@ public:
/// Constructor which connects to the given Redis host/port. /// Constructor which connects to the given Redis host/port.
virtual ~Client(); virtual ~Client();
/// Destructor. /// Destroys the Client.
Net::SocketAddress address() const; Net::SocketAddress address() const;
/// Returns the address of the Redis connection. /// Returns the address of the Redis connection.
@@ -125,9 +125,9 @@ public:
/// ///
/// A specialization exists for type void, which doesn't read /// A specialization exists for type void, which doesn't read
/// the reply. If the server sends a reply, it is your /// the reply. If the server sends a reply, it is your
/// responsibility to read it ... (Use this for pipelining) /// responsibility to read it. Use this for pipelining.
/// ///
/// A BadCastException will be thrown when the reply couldn't be /// A Poco::BadCastException will be thrown when the reply couldn't be
/// 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.
@@ -179,13 +179,9 @@ public:
/// Sets a receive timeout. /// Sets a receive timeout.
private: private:
Client(const Client&); Client(const Client&);
Client& operator = (const Client&); Client& operator = (const Client&);
Net::SocketAddress _address;
Net::StreamSocket _socket;
void connect(); void connect();
/// Connects to the Redis server /// Connects to the Redis server
@@ -198,28 +194,38 @@ private:
/// call readReply as many times as you called writeCommand, even when /// call readReply as many times as you called writeCommand, even when
/// an error occurred on a command. /// an error occurred on a command.
Net::SocketAddress _address;
Net::StreamSocket _socket;
RedisInputStream* _input; RedisInputStream* _input;
RedisOutputStream* _output; RedisOutputStream* _output;
}; };
//
// inlines
//
inline Net::SocketAddress Client::address() const inline Net::SocketAddress Client::address() const
{ {
return _address; return _address;
} }
template<> inline template<> inline
void Client::execute<void>(const Array& command) void Client::execute<void>(const Array& command)
{ {
writeCommand(command, false); writeCommand(command, false);
} }
inline void Client::flush() inline void Client::flush()
{ {
poco_assert(_output); poco_assert(_output);
_output->flush(); _output->flush();
} }
inline void Client::setReceiveTimeout(const Timespan& timeout) inline void Client::setReceiveTimeout(const Timespan& timeout)
{ {
_socket.setReceiveTimeout(timeout); _socket.setReceiveTimeout(timeout);

View File

@@ -9,31 +9,37 @@
// //
// Definition of the Command class. // Definition of the Command class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#ifndef Redis_Command_INCLUDED #ifndef Redis_Command_INCLUDED
#define Redis_Command_INCLUDED #define Redis_Command_INCLUDED
#include "Poco/Redis/Redis.h" #include "Poco/Redis/Redis.h"
#include "Poco/Redis/Array.h" #include "Poco/Redis/Array.h"
#include <vector> #include <vector>
#include <map> #include <map>
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
class Redis_API Command: public Array class Redis_API Command: public Array
/// Helper class for creating commands. This class contains /// Helper class for creating commands. This class contains
/// factory methods for commonly used Redis commands. /// factory methods for commonly used Redis commands.
///
/// There are two ways of building commands: /// There are two ways of building commands:
///
/// 1. Use this class and the factory methods /// 1. Use this class and the factory methods
/// 2. Use the Array or Command class and build the command using the add /// 2. Use the Array or Command class and build the command using the add
/// method or << operator. /// method or << operator.
///
/// For example: /// For example:
/// ///
/// Command cmd = Command::set("mykey", "Hello"); /// Command cmd = Command::set("mykey", "Hello");
@@ -45,212 +51,213 @@ class Redis_API Command : public Array
/// ///
{ {
public: public:
typedef std::vector<std::string> StringVec; typedef std::vector<std::string> StringVec;
Command(const std::string& command); Command(const std::string& command);
/// Constructor /// Creates a command.
Command(const Command& copy); Command(const Command& copy);
/// Copy constructor /// Creates a command by copying another one.
virtual ~Command(); virtual ~Command();
/// Destructor /// Destroys the command.
static Command append(const std::string& key, const std::string& value); static Command append(const std::string& key, const std::string& value);
/// Returns an APPEND command /// Creates and returns an APPEND command.
static Command blpop(const StringVec& lists, Int64 timeout = 0); static Command blpop(const StringVec& lists, Int64 timeout = 0);
/// Returns a BLPOP command /// Creates and returns a BLPOP command.
static Command brpop(const StringVec& lists, Int64 timeout = 0); static Command brpop(const StringVec& lists, Int64 timeout = 0);
/// Returns a BRPOP command /// Creates and returns a BRPOP command.
static Command brpoplpush(const std::string& sourceList, const std::string& destinationList, Int64 timeout = 0); static Command brpoplpush(const std::string& sourceList, const std::string& destinationList, Int64 timeout = 0);
/// Returns a BRPOPLPUSH command /// Creates and returns a BRPOPLPUSH command.
static Command decr(const std::string& key, Int64 by = 0); static Command decr(const std::string& key, Int64 by = 0);
/// Returns an DECR or DECRBY command. Calls DECR when by is omitted or zero. /// Creates and returns an DECR or DECRBY command. Calls DECR when by is omitted or zero.
static Command del(const std::string& key); static Command del(const std::string& key);
/// Returns an DEL command /// Creates and returns an DEL command.
static Command del(const StringVec& keys); static Command del(const StringVec& keys);
/// Returns an DEL command /// Creates and returns an DEL command.
static Command get(const std::string& key); static Command get(const std::string& key);
/// Returns an GET command /// Creates and returns an GET command.
static Command hdel(const std::string& hash, const std::string& field); static Command hdel(const std::string& hash, const std::string& field);
/// Returns an HDEL command /// Creates and returns an HDEL command.
static Command hdel(const std::string& hash, const StringVec& fields); static Command hdel(const std::string& hash, const StringVec& fields);
/// Returns an HDEL command /// Creates and returns an HDEL command.
static Command hexists(const std::string& hash, const std::string& field); static Command hexists(const std::string& hash, const std::string& field);
/// Returns an HEXISTS command /// Creates and returns an HEXISTS command.
static Command hget(const std::string& hash, const std::string& field); static Command hget(const std::string& hash, const std::string& field);
/// Returns an HGET command /// Creates and returns an HGET command.
static Command hgetall(const std::string& hash); static Command hgetall(const std::string& hash);
/// Returns an HGETALL command /// Creates and returns an HGETALL command.
static Command hincrby(const std::string& hash, const std::string& field, Int64 by = 1); static Command hincrby(const std::string& hash, const std::string& field, Int64 by = 1);
/// Returns an HINCRBY command /// Creates and returns an HINCRBY command.
static Command hkeys(const std::string& hash); static Command hkeys(const std::string& hash);
/// Returns an HKEYS command /// Creates and returns an HKEYS command.
static Command hlen(const std::string& hash); static Command hlen(const std::string& hash);
/// Returns an HLEN command /// Creates and returns an HLEN command.
static Command hmget(const std::string& hash, const StringVec& fields); static Command hmget(const std::string& hash, const StringVec& fields);
/// Returns an HMGET command /// Creates and returns an HMGET command.
static Command hmset(const std::string& hash, std::map<std::string, std::string>& fields); static Command hmset(const std::string& hash, std::map<std::string, std::string>& fields);
/// Returns a HMSET command /// Creates and returns a HMSET command.
static Command hset(const std::string& hash, const std::string& field, const std::string& value, bool create = true); static Command hset(const std::string& hash, const std::string& field, const std::string& value, bool create = true);
/// Returns an HSET or HSETNX (when create is false) command /// Creates and returns an HSET or HSETNX (when create is false) command.
static Command hset(const std::string& hash, const std::string& field, Int64 value, bool create = true); static Command hset(const std::string& hash, const std::string& field, Int64 value, bool create = true);
/// Returns an HSET or HSETNX (when create is false) command /// Creates and returns an HSET or HSETNX (when create is false) command.
static Command hstrlen(const std::string& hash, const std::string& field); static Command hstrlen(const std::string& hash, const std::string& field);
/// Returns an HSTRLEN command (Available for Redis 3.2) /// Creates and returns an HSTRLEN command (Available for Redis 3.2).
static Command hvals(const std::string& hash); static Command hvals(const std::string& hash);
/// Returns an HVALS command /// Creates and returns an HVALS command.
static Command incr(const std::string& key, Int64 by = 0); static Command incr(const std::string& key, Int64 by = 0);
/// Returns an INCR or INCRBY command. Calls INCR when by is omitted or zero. /// Creates and returns an INCR or INCRBY command. Calls INCR when by is omitted or zero.
static Command lindex(const std::string& list, Int64 index = 0); static Command lindex(const std::string& list, Int64 index = 0);
/// Returns a LINDEX command /// Creates and returns a LINDEX command.
static Command linsert(const std::string& list, bool before, const std::string& reference, const std::string& value); static Command linsert(const std::string& list, bool before, const std::string& reference, const std::string& value);
/// Returns a LINSERT command /// Creates and returns a LINSERT command.
static Command llen(const std::string& list); static Command llen(const std::string& list);
/// Returns a LLEN command /// Creates and returns a LLEN command.
static Command lpop(const std::string& list); static Command lpop(const std::string& list);
/// Returns a LPOP command /// Creates and returns a LPOP command.
static Command lpush(const std::string& list, const std::string& value, bool create = true); static Command lpush(const std::string& list, const std::string& value, bool create = true);
/// Returns a LPUSH or LPUSHX (when create is false) command /// Creates and returns a LPUSH or LPUSHX (when create is false) command.
static Command lpush(const std::string& list, const StringVec& value, bool create = true); static Command lpush(const std::string& list, const StringVec& value, bool create = true);
/// Returns a LPUSH or LPUSHX (when create is false) command /// Creates and returns a LPUSH or LPUSHX (when create is false) command.
static Command lrange(const std::string& list, Int64 start = 0, Int64 stop = -1); static Command lrange(const std::string& list, Int64 start = 0, Int64 stop = -1);
/// Returns a LRANGE command. When start and stop is omitted an LRANGE /// Creates and returns a LRANGE command. When start and stop is omitted an LRANGE
/// command will returned that returns all items of the list. /// command will returned that returns all items of the list.
static Command lrem(const std::string& list, Int64 count, const std::string& value); static Command lrem(const std::string& list, Int64 count, const std::string& value);
/// Returns a LREM command /// Creates and returns a LREM command.
static Command lset(const std::string& list, Int64 index, const std::string& value); static Command lset(const std::string& list, Int64 index, const std::string& value);
/// Returns a LSET command /// Creates and returns a LSET command.
static Command ltrim(const std::string& list, Int64 start = 0, Int64 stop = -1); static Command ltrim(const std::string& list, Int64 start = 0, Int64 stop = -1);
/// Returns a LTRIM command /// Creates and returns a LTRIM command.
static Command mget(const StringVec& keys); static Command mget(const StringVec& keys);
/// Returns a MGET command /// Creates and returns a MGET command.
static Command mset(const std::map<std::string, std::string>& keyvalues, bool create = true); static Command mset(const std::map<std::string, std::string>& keyvalues, bool create = true);
/// Returns a MSET or MSETNX (when create is false) command /// Creates and returns a MSET or MSETNX (when create is false) command.
static Command sadd(const std::string& set, const std::string& value); static Command sadd(const std::string& set, const std::string& value);
/// Returns a SADD command /// Creates and returns a SADD command.
static Command sadd(const std::string& set, const StringVec& values); static Command sadd(const std::string& set, const StringVec& values);
/// Returns a SADD command /// Creates and returns a SADD command.
static Command scard(const std::string& set); static Command scard(const std::string& set);
/// Returns a SCARD command /// Creates and returns a SCARD command.
static Command sdiff(const std::string& set1, const std::string& set2); static Command sdiff(const std::string& set1, const std::string& set2);
/// Returns a SDIFF command /// Creates and returns a SDIFF command.Creates and returns
static Command sdiff(const std::string& set, const StringVec& sets); static Command sdiff(const std::string& set, const StringVec& sets);
/// Returns a SDIFF command /// Creates and returns a SDIFF command.
static Command sdiffstore(const std::string& set, const std::string& set1, const std::string& set2); static Command sdiffstore(const std::string& set, const std::string& set1, const std::string& set2);
/// Returns a SDIFFSTORE command /// Creates and returns a SDIFFSTORE command.
static Command sdiffstore(const std::string& set, const StringVec& sets); static Command sdiffstore(const std::string& set, const StringVec& sets);
/// Returns a SDIFFSTORE command /// Creates and returns a SDIFFSTORE command.
static Command set(const std::string& key, const std::string& value, bool overwrite = true, const Poco::Timespan& expireTime = 0, bool create = true); static Command set(const std::string& key, const std::string& value, bool overwrite = true, const Poco::Timespan& expireTime = 0, bool create = true);
/// Returns a SET command to set the key with a value /// Creates and returns a SET command to set the key with a value.
static Command set(const std::string& key, Int64 value, bool overwrite = true, const Poco::Timespan& expireTime = 0, bool create = true); static Command set(const std::string& key, Int64 value, bool overwrite = true, const Poco::Timespan& expireTime = 0, bool create = true);
/// Returns a SET command to set the key with a value /// Creates and returns a SET command to set the key with a value.
static Command sinter(const std::string& set1, const std::string& set2); static Command sinter(const std::string& set1, const std::string& set2);
/// Returns a SINTER command /// Creates and returns a SINTER command.
static Command sinter(const std::string& set, const StringVec& sets); static Command sinter(const std::string& set, const StringVec& sets);
/// Returns a SINTER command /// Creates and returns a SINTER command.
static Command sinterstore(const std::string& set, const std::string& set1, const std::string& set2); static Command sinterstore(const std::string& set, const std::string& set1, const std::string& set2);
/// Returns a SINTERSTORE command /// Creates and returns a SINTERSTORE command.
static Command sinterstore(const std::string& set, const StringVec& sets); static Command sinterstore(const std::string& set, const StringVec& sets);
/// Returns a SINTERSTORE command /// Creates and returns a SINTERSTORE command.
static Command sismember(const std::string& set, const std::string& member); static Command sismember(const std::string& set, const std::string& member);
/// Returns a SISMEMBER command /// Creates and returns a SISMEMBER command.
static Command smembers(const std::string& set); static Command smembers(const std::string& set);
/// Returns a SMEMBERS command /// Creates and returns a SMEMBERS command.
static Command smove(const std::string& source, const std::string& destination, const std::string& member); static Command smove(const std::string& source, const std::string& destination, const std::string& member);
/// Returns a SMOVE command /// Creates and returns a SMOVE command.
static Command spop(const std::string& set, Int64 count = 0); static Command spop(const std::string& set, Int64 count = 0);
/// Returns a SPOP command /// Creates and returns a SPOP command.
static Command srandmember(const std::string& set, Int64 count = 0); static Command srandmember(const std::string& set, Int64 count = 0);
/// Returns a SRANDMEMBER command /// Creates and returns a SRANDMEMBER command.
static Command srem(const std::string& set, const std::string& member); static Command srem(const std::string& set, const std::string& member);
/// Returns a SREM command /// Creates and returns a SREM command.
static Command srem(const std::string& set, const StringVec& members); static Command srem(const std::string& set, const StringVec& members);
/// Returns a SREM command /// Creates and returns a SREM command.
static Command sunion(const std::string& set1, const std::string& set2); static Command sunion(const std::string& set1, const std::string& set2);
/// Returns a SUNION command /// Creates and returns a SUNION command.
static Command sunion(const std::string& set, const StringVec& sets); static Command sunion(const std::string& set, const StringVec& sets);
/// Returns a SUNION command /// Creates and returns a SUNION command.
static Command sunionstore(const std::string& set, const std::string& set1, const std::string& set2); static Command sunionstore(const std::string& set, const std::string& set1, const std::string& set2);
/// Returns a SUNIONSTORE command /// Creates and returns a SUNIONSTORE command.
static Command sunionstore(const std::string& set, const StringVec& sets); static Command sunionstore(const std::string& set, const StringVec& sets);
/// Returns a SUNIONSTORE command /// Creates and returns a SUNIONSTORE command.
static Command rename(const std::string& key, const std::string& newName, bool overwrite = true); static Command rename(const std::string& key, const std::string& newName, bool overwrite = true);
/// Returns a RENAME or RENAMENX when overwrite is false /// Creates and returns a RENAME or RENAMENX when overwrite is false.
static Command rpop(const std::string& list); static Command rpop(const std::string& list);
/// Returns a RPOP command /// Creates and returns a RPOP command.
static Command rpoplpush(const std::string& sourceList, const std::string& destinationList); static Command rpoplpush(const std::string& sourceList, const std::string& destinationList);
/// Returns a RPOPLPUSH command /// Creates and returns a RPOPLPUSH command.
static Command rpush(const std::string& list, const std::string& value, bool create = true); static Command rpush(const std::string& list, const std::string& value, bool create = true);
/// Returns a RPUSH or RPUSHX (when create is false) command /// Creates and returns a RPUSH or RPUSHX (when create is false) command.
static Command rpush(const std::string& list, const StringVec& value, bool create = true); static Command rpush(const std::string& list, const StringVec& value, bool create = true);
/// Returns a RPUSH or RPUSHX (when create is false) command /// Creates and returns a RPUSH or RPUSHX (when create is false) command.
}; };
} } // namespace Poco::Redis } } // namespace Poco::Redis
#endif // Redis_Command_INCLUDED #endif // Redis_Command_INCLUDED

View File

@@ -9,55 +9,65 @@
// //
// Definition of the Error class. // Definition of the Error class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#ifndef Redis_Error_INCLUDED #ifndef Redis_Error_INCLUDED
#define Redis_Error_INCLUDED #define Redis_Error_INCLUDED
#include "Poco/Redis/Type.h" #include "Poco/Redis/Type.h"
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
class Redis_API Error class Redis_API Error
/// Represent a Redis error /// Represent a Redis error.
{ {
public: public:
Error(); Error();
/// Constructor /// Creates an empty Error.
Error(const std::string& message); Error(const std::string& message);
/// Constructor /// Creates an Error with the given message.
virtual ~Error(); virtual ~Error();
/// Destructor /// Destroys the Error.
std::string getMessage() const; const std::string& getMessage() const;
/// Returns the error message /// Returns the error message.
void setMessage(const std::string& message); void setMessage(const std::string& message);
/// Sets the error message /// Sets the error message.
private: private:
std::string _message; std::string _message;
}; };
inline std::string Error::getMessage() const
//
// inlines
//
inline const std::string& Error::getMessage() const
{ {
return _message; return _message;
} }
inline void Error::setMessage(const std::string& message) inline void Error::setMessage(const std::string& message)
{ {
_message = message; _message = message;
} }
template<> template<>
struct RedisTypeTraits<Error> struct RedisTypeTraits<Error>
{ {
@@ -76,6 +86,8 @@ struct RedisTypeTraits<Error>
} }
}; };
}} // Namespace Poco::Redis
} } // namespace Poco::Redis
#endif // Redis_Error_INCLUDED #endif // Redis_Error_INCLUDED

View File

@@ -9,24 +9,30 @@
// //
// Definition of the Exception class. // Definition of the Exception class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#ifndef Redis_Exception_INCLUDED #ifndef Redis_Exception_INCLUDED
#define Redis_Exception_INCLUDED #define Redis_Exception_INCLUDED
#include "Poco/Redis/Redis.h" #include "Poco/Redis/Redis.h"
#include <typeinfo>
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include <typeinfo>
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
POCO_DECLARE_EXCEPTION(Redis_API, RedisException, Exception) POCO_DECLARE_EXCEPTION(Redis_API, RedisException, Exception)
}}
} } // namespace Poco::Redis
#endif // Redis_Exception_INCLUDED #endif // Redis_Exception_INCLUDED

View File

@@ -9,7 +9,7 @@
// //
// Definition of the PoolableConnectionFactory class. // Definition of the PoolableConnectionFactory class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
@@ -22,6 +22,7 @@
#include "Poco/Redis/Client.h" #include "Poco/Redis/Client.h"
#include "Poco/ObjectPool.h" #include "Poco/ObjectPool.h"
#include "Poco/Version.h"
namespace Poco { namespace Poco {
@@ -33,13 +34,13 @@ class PoolableObjectFactory<Redis::Client, Redis::Client::Ptr>
/// are created with the given address. /// are created with the given address.
{ {
public: public:
PoolableObjectFactory(Net::SocketAddress& address) PoolableObjectFactory(Net::SocketAddress& address):
: _address(address) _address(address)
{ {
} }
PoolableObjectFactory(const std::string& address) PoolableObjectFactory(const std::string& address):
: _address(address) _address(address)
{ {
} }
@@ -79,7 +80,11 @@ class PooledConnection
public: public:
PooledConnection(ObjectPool<Client, Client::Ptr>& pool, long timeoutMilliseconds = 0) : _pool(pool) PooledConnection(ObjectPool<Client, Client::Ptr>& pool, long timeoutMilliseconds = 0) : _pool(pool)
{ {
#if POCO_VERSION >= 0x01080000
_client = _pool.borrowObject(timeoutMilliseconds); _client = _pool.borrowObject(timeoutMilliseconds);
#else
_client = _pool.borrowObject();
#endif
} }
virtual ~PooledConnection() virtual ~PooledConnection()
@@ -105,7 +110,7 @@ private:
}; };
} // namespace Redis } } // namespace Poco::Redis
} // namespace Poco
#endif // Redis_PoolableConnectionFactory_INCLUDED #endif // Redis_PoolableConnectionFactory_INCLUDED

View File

@@ -11,7 +11,7 @@
// This file must be the first file included by every other Redis // This file must be the first file included by every other Redis
// header file. // header file.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
@@ -33,8 +33,6 @@
// Redis_API functions as being imported from a DLL, wheras this DLL sees symbols // Redis_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported. // defined with this macro as being exported.
// //
#if defined(_WIN32) && defined(POCO_DLL) #if defined(_WIN32) && defined(POCO_DLL)
#if defined(Redis_EXPORTS) #if defined(Redis_EXPORTS)
#define Redis_API __declspec(dllexport) #define Redis_API __declspec(dllexport)

View File

@@ -9,47 +9,53 @@
// //
// Definition of the RedisEventArgs class. // Definition of the RedisEventArgs class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#ifndef Redis_RedisEventArgs_INCLUDED #ifndef Redis_RedisEventArgs_INCLUDED
#define Redis_RedisEventArgs_INCLUDED #define Redis_RedisEventArgs_INCLUDED
#include "Poco/Redis/Type.h" #include "Poco/Redis/Type.h"
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
class Redis_API RedisEventArgs class Redis_API RedisEventArgs
/// Event arguments for AsyncReader events.
{ {
public: public:
RedisEventArgs(RedisType::Ptr message); RedisEventArgs(RedisType::Ptr message);
/// Constructor /// Creates the RedisEventArgs from the given message.
RedisEventArgs(Exception* e); RedisEventArgs(Exception* e);
/// Constructor /// Creates the RedisEventArgs from the given Redis Exception.
~RedisEventArgs(); ~RedisEventArgs();
/// Destructor /// Destroys the RedisEventArgs.
RedisType::Ptr message() const; RedisType::Ptr message() const;
/// Returns the message retrieved from the Redis server. /// Returns the message retrieved from the Redis server.
/// This can be a NULL pointer when this event is about an exception. /// This can be a NULL pointer when this event is about an exception.
const Exception* exception() const; const Exception* exception() const;
/// Returns the exception if any, otherwise it returns null pointer /// Returns the exception if any, otherwise it returns null pointer.
void stop(); void stop();
/// When called, the AsyncReader will stop. /// When called, the AsyncReader will stop.
///
/// Note: The AsyncReader will always stop when this is an exception /// Note: The AsyncReader will always stop when this is an exception
/// event. Use this for example for pub/sub when there are no /// event. Use this for example for pub/sub when there are no
/// subcribers anymore ... /// subcribers anymore.
bool isStopped() const; bool isStopped() const;
/// Returns true when the AsyncReader will stop /// Returns true when the AsyncReader will stop.
private: private:
RedisType::Ptr _message; RedisType::Ptr _message;
@@ -59,21 +65,30 @@ private:
bool _stop; bool _stop;
}; };
//
// inlines
//
inline RedisType::Ptr RedisEventArgs::message() const inline RedisType::Ptr RedisEventArgs::message() const
{ {
return _message; return _message;
} }
inline const Exception* RedisEventArgs::exception() const inline const Exception* RedisEventArgs::exception() const
{ {
return _exception; return _exception;
} }
inline bool RedisEventArgs::isStopped() const inline bool RedisEventArgs::isStopped() const
{ {
return _stop; return _stop;
} }
inline void RedisEventArgs::stop() inline void RedisEventArgs::stop()
{ {
_stop = true; _stop = true;
@@ -82,4 +97,5 @@ inline void RedisEventArgs::stop()
} } // namespace Poco::Redis } } // namespace Poco::Redis
#endif // Redis_RedisEventArgs_INCLUDED #endif // Redis_RedisEventArgs_INCLUDED

View File

@@ -9,27 +9,30 @@
// //
// Definition of the RedisStream class. // Definition of the RedisStream class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#ifndef Redis_RedisStream_INCLUDED #ifndef Redis_RedisStream_INCLUDED
#define Redis_RedisStream_INCLUDED #define Redis_RedisStream_INCLUDED
#include "Poco/Redis/Redis.h" #include "Poco/Redis/Redis.h"
#include "Poco/BufferedStreamBuf.h" #include "Poco/BufferedStreamBuf.h"
#include "Poco/Net/StreamSocket.h" #include "Poco/Net/StreamSocket.h"
#include <istream> #include <istream>
#include <ostream> #include <ostream>
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
class RedisStreamBuf: public BufferedStreamBuf class RedisStreamBuf: public BufferedStreamBuf
/// BufferedStreamBuf for Redis /// BufferedStreamBuf for Redis.
{ {
public: public:
RedisStreamBuf(Net::StreamSocket& redis); RedisStreamBuf(Net::StreamSocket& redis);
@@ -43,11 +46,9 @@ public:
protected: protected:
int readFromDevice(char* buffer, std::streamsize length); int readFromDevice(char* buffer, std::streamsize length);
int writeToDevice(const char* buffer, std::streamsize length); int writeToDevice(const char* buffer, std::streamsize length);
private: private:
enum enum
{ {
STREAM_BUFFER_SIZE = 1024 STREAM_BUFFER_SIZE = 1024
@@ -56,6 +57,7 @@ private:
Net::StreamSocket& _redis; Net::StreamSocket& _redis;
}; };
class RedisIOS: public virtual std::ios class RedisIOS: public virtual std::ios
{ {
public: public:
@@ -103,11 +105,12 @@ public:
/// Destroys the RedisInputStream. /// Destroys the RedisInputStream.
std::string getline(); std::string getline();
/// Redis uses /r/n as delimiter. This getline version removes /// Redis uses \r\n as delimiter. This getline version removes
/// the /r from the result. /// the \r from the result.
}; };
}} // Poco::Redis } } // namespace Poco::Redis
#endif // Redis_RedisStream_INCLUDED #endif // Redis_RedisStream_INCLUDED

View File

@@ -9,24 +9,26 @@
// //
// Definition of the Type class. // Definition of the Type class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2016, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#ifndef Redis_Type_INCLUDED #ifndef Redis_Type_INCLUDED
#define Redis_Type_INCLUDED #define Redis_Type_INCLUDED
#include "Poco/LineEndingConverter.h" #include "Poco/LineEndingConverter.h"
#include "Poco/NumberFormatter.h" #include "Poco/NumberFormatter.h"
#include "Poco/NumberParser.h" #include "Poco/NumberParser.h"
#include "Poco/SharedPtr.h" #include "Poco/SharedPtr.h"
#include "Poco/Nullable.h" #include "Poco/Nullable.h"
#include "Poco/Redis/Redis.h" #include "Poco/Redis/Redis.h"
#include "Poco/Redis/RedisStream.h" #include "Poco/Redis/RedisStream.h"
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
@@ -36,22 +38,22 @@ class Redis_API RedisType
/// element with different types in Array. /// element with different types in Array.
{ {
public: public:
enum Types
enum Types { {
REDIS_INTEGER, // Redis Integer REDIS_INTEGER, /// Redis Integer
REDIS_SIMPLE_STRING, // Redis Simple String REDIS_SIMPLE_STRING, /// Redis Simple String
REDIS_BULK_STRING, // Redis Bulkstring REDIS_BULK_STRING, /// Redis Bulkstring
REDIS_ARRAY, // Redis Array REDIS_ARRAY, /// Redis Array
REDIS_ERROR // Redis Error REDIS_ERROR /// Redis Error
}; };
typedef SharedPtr<RedisType> Ptr; typedef SharedPtr<RedisType> Ptr;
RedisType(); RedisType();
/// Constructor /// Creates the RedisType.
virtual ~RedisType(); virtual ~RedisType();
/// Destructor /// Destroys the RedisType.
bool isArray() const; bool isArray() const;
/// Returns true when the value is a Redis array. /// Returns true when the value is a Redis array.
@@ -63,7 +65,7 @@ public:
/// Returns true when the value is a Redis error. /// Returns true when the value is a Redis error.
bool isInteger() const; bool isInteger() const;
/// Returns true when the value is a Redis integer (64 bit integer) /// Returns true when the value is a Redis integer (64 bit integer).
bool isSimpleString() const; bool isSimpleString() const;
/// Returns true when the value is a simple string. /// Returns true when the value is a simple string.
@@ -79,41 +81,50 @@ public:
static RedisType::Ptr createRedisType(char marker); static RedisType::Ptr createRedisType(char marker);
/// Create a Redis type based on the marker: /// Create a Redis type based on the marker:
/// + : a simple string (std::string) ///
/// - : an error (Error) /// - '+': a simple string (std::string)
/// $ : a bulk string (BulkString) /// - '-': an error (Error)
/// * : an array (Array) /// - '$': a bulk string (BulkString)
/// : : a signed 64 bit integer (Int64) /// - '*': an array (Array)
/// - ':': a signed 64 bit integer (Int64)
private:
}; };
//
// inlines
//
inline bool RedisType::isArray() const inline bool RedisType::isArray() const
{ {
return type() == REDIS_ARRAY; return type() == REDIS_ARRAY;
} }
inline bool RedisType::isBulkString() const inline bool RedisType::isBulkString() const
{ {
return type() == REDIS_BULK_STRING; return type() == REDIS_BULK_STRING;
} }
inline bool RedisType::isError() const inline bool RedisType::isError() const
{ {
return type() == REDIS_ERROR; return type() == REDIS_ERROR;
} }
inline bool RedisType::isInteger() const inline bool RedisType::isInteger() const
{ {
return type() == REDIS_INTEGER; return type() == REDIS_INTEGER;
} }
inline bool RedisType::isSimpleString() const inline bool RedisType::isSimpleString() const
{ {
return type() == REDIS_SIMPLE_STRING; return type() == REDIS_SIMPLE_STRING;
} }
template<typename T> template<typename T>
struct RedisTypeTraits struct RedisTypeTraits
{ {
@@ -123,7 +134,10 @@ struct RedisTypeTraits
template<> template<>
struct RedisTypeTraits<Int64> struct RedisTypeTraits<Int64>
{ {
enum { TypeId = RedisType::REDIS_INTEGER }; enum
{
TypeId = RedisType::REDIS_INTEGER
};
static const char marker = ':'; static const char marker = ':';
@@ -137,14 +151,16 @@ struct RedisTypeTraits<Int64>
std::string number = input.getline(); std::string number = input.getline();
value = NumberParser::parse64(number); value = NumberParser::parse64(number);
} }
}; };
template<> template<>
struct RedisTypeTraits<std::string> struct RedisTypeTraits<std::string>
{ {
enum { TypeId = RedisType::REDIS_SIMPLE_STRING }; enum
{
TypeId = RedisType::REDIS_SIMPLE_STRING
};
static const char marker = '+'; static const char marker = '+';
@@ -168,7 +184,10 @@ typedef Nullable<std::string> BulkString;
template<> template<>
struct RedisTypeTraits<BulkString> struct RedisTypeTraits<BulkString>
{ {
enum { TypeId = RedisType::REDIS_BULK_STRING }; enum
{
TypeId = RedisType::REDIS_BULK_STRING
};
static const char marker = '$'; static const char marker = '$';
@@ -215,24 +234,23 @@ class Type : public RedisType
/// RedisTypeTraits structure for calling the type specific code. /// RedisTypeTraits structure for calling the type specific code.
{ {
public: public:
Type() Type()
/// Constructor /// Creates the Type.
{ {
} }
Type(const T& t) : _value(t) Type(const T& t) : _value(t)
/// Constructor /// Creates the Type from another one.
{ {
} }
Type(const Type& copy) : _value(copy._value) Type(const Type& copy) : _value(copy._value)
/// Copy Constructor /// Creates the Type by copying another one.
{ {
} }
virtual ~Type() virtual ~Type()
/// Destructor /// Destroys the Type.
{ {
} }
@@ -267,10 +285,11 @@ public:
} }
private: private:
T _value; T _value;
}; };
}} // Namespace Poco/Redis
} } // namespace Poco/Redis
#endif // Redis_Type_INCLUDED #endif // Redis_Type_INCLUDED

View File

@@ -9,14 +9,16 @@
// //
// Implementation of the Array class. // Implementation of the Array class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#include "Poco/Redis/Array.h" #include "Poco/Redis/Array.h"
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
@@ -26,7 +28,8 @@ Array::Array()
} }
Array::Array(const Array& copy) : _elements(copy._elements) Array::Array(const Array& copy):
_elements(copy._elements)
{ {
} }
@@ -62,4 +65,5 @@ std::string Array::toString() const
return RedisTypeTraits<Array>::toString(*this); return RedisTypeTraits<Array>::toString(*this);
} }
} }
} } // namespace Poco::Redis

View File

@@ -9,19 +9,22 @@
// //
// Implementation of the AsyncReader class. // Implementation of the AsyncReader class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#include "Poco/Redis/AsyncReader.h" #include "Poco/Redis/AsyncReader.h"
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
AsyncReader::AsyncReader(Client& client) : _client(client), AsyncReader::AsyncReader(Client& client):
_client(client),
_activity(this, &AsyncReader::runActivity) _activity(this, &AsyncReader::runActivity)
{ {
} }
@@ -57,4 +60,4 @@ void AsyncReader::runActivity()
} }
} } // Poco::Redis } } // namespace Poco::Redis

View File

@@ -9,37 +9,55 @@
// //
// Implementation of the Client class. // Implementation of the Client class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#include "Poco/Redis/Client.h" #include "Poco/Redis/Client.h"
#include "Poco/Redis/Exception.h" #include "Poco/Redis/Exception.h"
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
Client::Client() : _address(), _socket(), _input(0), _output(0) Client::Client():
_address(),
_socket(),
_input(0),
_output(0)
{ {
} }
Client::Client(const std::string& hostAndPort) : _address(hostAndPort), _socket(), _input(0), _output(0) Client::Client(const std::string& hostAndPort):
_address(hostAndPort),
_socket(),
_input(0),
_output(0)
{ {
connect(); connect();
} }
Client::Client(const std::string& host, int port) : _address(host, port), _socket(), _input(0), _output(0) Client::Client(const std::string& host, int port):
_address(host, port),
_socket(),
_input(0),
_output(0)
{ {
connect(); connect();
} }
Client::Client(const Net::SocketAddress& addrs) : _address(addrs), _socket(), _input(0), _output(0) Client::Client(const Net::SocketAddress& addrs):
_address(addrs),
_socket(),
_input(0),
_output(0)
{ {
connect(); connect();
} }
@@ -62,6 +80,7 @@ void Client::connect()
_output = new RedisOutputStream(_socket); _output = new RedisOutputStream(_socket);
} }
void Client::connect(const std::string& hostAndPort) void Client::connect(const std::string& hostAndPort)
{ {
_address = Net::SocketAddress(hostAndPort); _address = Net::SocketAddress(hostAndPort);
@@ -82,6 +101,7 @@ void Client::connect(const Net::SocketAddress& addrs)
connect(); connect();
} }
void Client::connect(const Timespan& timeout) void Client::connect(const Timespan& timeout)
{ {
poco_assert(! _input); poco_assert(! _input);
@@ -92,6 +112,7 @@ void Client::connect(const Timespan& timeout)
_output = new RedisOutputStream(_socket); _output = new RedisOutputStream(_socket);
} }
void Client::connect(const std::string& hostAndPort, const Timespan& timeout) void Client::connect(const std::string& hostAndPort, const Timespan& timeout)
{ {
_address = Net::SocketAddress(hostAndPort); _address = Net::SocketAddress(hostAndPort);
@@ -112,6 +133,7 @@ void Client::connect(const Net::SocketAddress& addrs, const Timespan& timeout)
connect(timeout); connect(timeout);
} }
void Client::disconnect() void Client::disconnect()
{ {
delete _input; delete _input;
@@ -123,6 +145,7 @@ void Client::disconnect()
_socket.close(); _socket.close();
} }
void Client::writeCommand(const Array& command, bool doFlush) void Client::writeCommand(const Array& command, bool doFlush)
{ {
poco_assert(_output); poco_assert(_output);
@@ -133,6 +156,7 @@ void Client::writeCommand(const Array& command, bool doFlush)
if (doFlush) _output->flush(); if (doFlush) _output->flush();
} }
RedisType::Ptr Client::readReply() RedisType::Ptr Client::readReply()
{ {
poco_assert(_input); poco_assert(_input);
@@ -149,12 +173,14 @@ RedisType::Ptr Client::readReply()
return result; return result;
} }
RedisType::Ptr Client::sendCommand(const Array& command) RedisType::Ptr Client::sendCommand(const Array& command)
{ {
writeCommand(command, true); writeCommand(command, true);
return readReply(); return readReply();
} }
Array Client::sendCommands(const std::vector<Array>& commands) Array Client::sendCommands(const std::vector<Array>& commands)
{ {
Array results; Array results;
@@ -173,4 +199,5 @@ Array Client::sendCommands(const std::vector<Array>& commands)
return results; return results;
} }
} } // Poco::Redis
} } // namespace Poco::Redis

View File

@@ -9,31 +9,37 @@
// //
// Implementation of the Command class. // Implementation of the Command class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#include "Poco/Redis/Command.h" #include "Poco/Redis/Command.h"
#include "Poco/NumberFormatter.h" #include "Poco/NumberFormatter.h"
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
Command::Command(const std::string& command): Array() Command::Command(const std::string& command): Array()
{ {
add(command); add(command);
} }
Command::Command(const Command& copy): Array(copy) Command::Command(const Command& copy): Array(copy)
{ {
} }
Command::~Command() Command::~Command()
{ {
} }
Command Command::append(const std::string& key, const std::string& value) Command Command::append(const std::string& key, const std::string& value)
{ {
Command cmd("APPEND"); Command cmd("APPEND");
@@ -43,6 +49,7 @@ Command Command::append(const std::string& key, const std::string& value)
return cmd; return cmd;
} }
Command Command::blpop(const StringVec& lists, Int64 timeout) Command Command::blpop(const StringVec& lists, Int64 timeout)
{ {
Command cmd("BLPOP"); Command cmd("BLPOP");
@@ -52,6 +59,7 @@ Command Command::blpop(const StringVec& lists, Int64 timeout)
return cmd; return cmd;
} }
Command Command::brpop(const StringVec& lists, Int64 timeout) Command Command::brpop(const StringVec& lists, Int64 timeout)
{ {
Command cmd("BRPOP"); Command cmd("BRPOP");
@@ -61,6 +69,7 @@ Command Command::brpop(const StringVec& lists, Int64 timeout)
return cmd; return cmd;
} }
Command Command::brpoplpush(const std::string& sourceList, const std::string& destinationList, Int64 timeout) Command Command::brpoplpush(const std::string& sourceList, const std::string& destinationList, Int64 timeout)
{ {
Command cmd("BRPOPLPUSH"); Command cmd("BRPOPLPUSH");
@@ -70,6 +79,7 @@ Command Command::brpoplpush(const std::string& sourceList, const std::string& de
return cmd; return cmd;
} }
Command Command::decr(const std::string& key, Int64 by) Command Command::decr(const std::string& key, Int64 by)
{ {
Command cmd(by == 0 ? "DECR" : "DECRBY"); Command cmd(by == 0 ? "DECR" : "DECRBY");
@@ -80,6 +90,7 @@ Command Command::decr(const std::string& key, Int64 by)
return cmd; return cmd;
} }
Command Command::del(const std::string& key) Command Command::del(const std::string& key)
{ {
Command cmd("DEL"); Command cmd("DEL");
@@ -89,6 +100,7 @@ Command Command::del(const std::string& key)
return cmd; return cmd;
} }
Command Command::del(const StringVec& keys) Command Command::del(const StringVec& keys)
{ {
Command cmd("DEL"); Command cmd("DEL");
@@ -98,6 +110,7 @@ Command Command::del(const StringVec& keys)
return cmd; return cmd;
} }
Command Command::get(const std::string& key) Command Command::get(const std::string& key)
{ {
Command cmd("GET"); Command cmd("GET");
@@ -107,6 +120,7 @@ Command Command::get(const std::string& key)
return cmd; return cmd;
} }
Command Command::hdel(const std::string& hash, const std::string& field) Command Command::hdel(const std::string& hash, const std::string& field)
{ {
Command cmd("HDEL"); Command cmd("HDEL");
@@ -116,6 +130,7 @@ Command Command::hdel(const std::string& hash, const std::string& field)
return cmd; return cmd;
} }
Command Command::hdel(const std::string& hash, const StringVec& fields) Command Command::hdel(const std::string& hash, const StringVec& fields)
{ {
Command cmd("HDEL"); Command cmd("HDEL");
@@ -125,6 +140,7 @@ Command Command::hdel(const std::string& hash, const StringVec& fields)
return cmd; return cmd;
} }
Command Command::hexists(const std::string& hash, const std::string& field) Command Command::hexists(const std::string& hash, const std::string& field)
{ {
Command cmd("HEXISTS"); Command cmd("HEXISTS");
@@ -134,6 +150,7 @@ Command Command::hexists(const std::string& hash, const std::string& field)
return cmd; return cmd;
} }
Command Command::hget(const std::string& hash, const std::string& field) Command Command::hget(const std::string& hash, const std::string& field)
{ {
Command cmd("HGET"); Command cmd("HGET");
@@ -143,6 +160,7 @@ Command Command::hget(const std::string& hash, const std::string& field)
return cmd; return cmd;
} }
Command Command::hgetall(const std::string& hash) Command Command::hgetall(const std::string& hash)
{ {
Command cmd("HGETALL"); Command cmd("HGETALL");
@@ -152,6 +170,7 @@ Command Command::hgetall(const std::string& hash)
return cmd; return cmd;
} }
Command Command::hincrby(const std::string& hash, const std::string& field, Int64 by) Command Command::hincrby(const std::string& hash, const std::string& field, Int64 by)
{ {
Command cmd("HINCRBY"); Command cmd("HINCRBY");
@@ -161,6 +180,7 @@ Command Command::hincrby(const std::string& hash, const std::string& field, Int6
return cmd; return cmd;
} }
Command Command::hkeys(const std::string& hash) Command Command::hkeys(const std::string& hash)
{ {
Command cmd("HKEYS"); Command cmd("HKEYS");
@@ -170,6 +190,7 @@ Command Command::hkeys(const std::string& hash)
return cmd; return cmd;
} }
Command Command::hlen(const std::string& hash) Command Command::hlen(const std::string& hash)
{ {
Command cmd("HLEN"); Command cmd("HLEN");
@@ -179,6 +200,7 @@ Command Command::hlen(const std::string& hash)
return cmd; return cmd;
} }
Command Command::hmget(const std::string& hash, const StringVec& fields) Command Command::hmget(const std::string& hash, const StringVec& fields)
{ {
Command cmd("HMGET"); Command cmd("HMGET");
@@ -188,6 +210,7 @@ Command Command::hmget(const std::string& hash, const StringVec& fields)
return cmd; return cmd;
} }
Command Command::hmset(const std::string& hash, std::map<std::string, std::string>& fields) Command Command::hmset(const std::string& hash, std::map<std::string, std::string>& fields)
{ {
Command cmd("HMSET"); Command cmd("HMSET");
@@ -201,6 +224,7 @@ Command Command::hmset(const std::string& hash, std::map<std::string, std::strin
return cmd; return cmd;
} }
Command Command::hset(const std::string& hash, const std::string& field, const std::string& value, bool create) Command Command::hset(const std::string& hash, const std::string& field, const std::string& value, bool create)
{ {
Command cmd(create ? "HSET" : "HSETNX"); Command cmd(create ? "HSET" : "HSETNX");
@@ -210,11 +234,13 @@ Command Command::hset(const std::string& hash, const std::string& field, const s
return cmd; return cmd;
} }
Command Command::hset(const std::string& hash, const std::string& field, Int64 value, bool create) Command Command::hset(const std::string& hash, const std::string& field, Int64 value, bool create)
{ {
return hset(hash, field, NumberFormatter::format(value), create); return hset(hash, field, NumberFormatter::format(value), create);
} }
Command Command::hstrlen(const std::string& hash, const std::string& field) Command Command::hstrlen(const std::string& hash, const std::string& field)
{ {
Command cmd("HSTRLEN"); Command cmd("HSTRLEN");
@@ -224,6 +250,7 @@ Command Command::hstrlen(const std::string& hash, const std::string& field)
return cmd; return cmd;
} }
Command Command::hvals(const std::string& hash) Command Command::hvals(const std::string& hash)
{ {
Command cmd("HVALS"); Command cmd("HVALS");
@@ -233,6 +260,7 @@ Command Command::hvals(const std::string& hash)
return cmd; return cmd;
} }
Command Command::incr(const std::string& key, Int64 by) Command Command::incr(const std::string& key, Int64 by)
{ {
Command cmd(by == 0 ? "INCR" : "INCRBY"); Command cmd(by == 0 ? "INCR" : "INCRBY");
@@ -243,6 +271,7 @@ Command Command::incr(const std::string& key, Int64 by)
return cmd; return cmd;
} }
Command Command::lindex(const std::string& list, Int64 index) Command Command::lindex(const std::string& list, Int64 index)
{ {
Command cmd("LINDEX"); Command cmd("LINDEX");
@@ -252,6 +281,7 @@ Command Command::lindex(const std::string& list, Int64 index)
return cmd; return cmd;
} }
Command Command::linsert(const std::string& list, bool before, const std::string& reference, const std::string& value) Command Command::linsert(const std::string& list, bool before, const std::string& reference, const std::string& value)
{ {
Command cmd("LINSERT"); Command cmd("LINSERT");
@@ -260,6 +290,7 @@ Command Command::linsert(const std::string& list, bool before, const std::string
return cmd; return cmd;
} }
Command Command::llen(const std::string& list) Command Command::llen(const std::string& list)
{ {
Command cmd("LLEN"); Command cmd("LLEN");
@@ -269,6 +300,7 @@ Command Command::llen(const std::string& list)
return cmd; return cmd;
} }
Command Command::lpop(const std::string& list) Command Command::lpop(const std::string& list)
{ {
Command cmd("LPOP"); Command cmd("LPOP");
@@ -278,6 +310,7 @@ Command Command::lpop(const std::string& list)
return cmd; return cmd;
} }
Command Command::lpush(const std::string& list, const std::string& value, bool create) Command Command::lpush(const std::string& list, const std::string& value, bool create)
{ {
Command cmd(create ? "LPUSH" : "LPUSHX"); Command cmd(create ? "LPUSH" : "LPUSHX");
@@ -287,6 +320,7 @@ Command Command::lpush(const std::string& list, const std::string& value, bool c
return cmd; return cmd;
} }
Command Command::lpush(const std::string& list, const StringVec& values, bool create) Command Command::lpush(const std::string& list, const StringVec& values, bool create)
{ {
Command cmd(create ? "LPUSH" : "LPUSHX"); Command cmd(create ? "LPUSH" : "LPUSHX");
@@ -296,6 +330,7 @@ Command Command::lpush(const std::string& list, const StringVec& values, bool cr
return cmd; return cmd;
} }
Command Command::lrange(const std::string& list, Int64 start, Int64 stop) Command Command::lrange(const std::string& list, Int64 start, Int64 stop)
{ {
Command cmd("LRANGE"); Command cmd("LRANGE");
@@ -305,6 +340,7 @@ Command Command::lrange(const std::string& list, Int64 start, Int64 stop)
return cmd; return cmd;
} }
Command Command::lrem(const std::string& list, Int64 count, const std::string& value) Command Command::lrem(const std::string& list, Int64 count, const std::string& value)
{ {
Command cmd("LREM"); Command cmd("LREM");
@@ -314,6 +350,7 @@ Command Command::lrem(const std::string& list, Int64 count, const std::string& v
return cmd; return cmd;
} }
Command Command::lset(const std::string& list, Int64 index, const std::string& value) Command Command::lset(const std::string& list, Int64 index, const std::string& value)
{ {
Command cmd("LSET"); Command cmd("LSET");
@@ -323,6 +360,7 @@ Command Command::lset(const std::string& list, Int64 index, const std::string& v
return cmd; return cmd;
} }
Command Command::ltrim(const std::string& list, Int64 start, Int64 stop) Command Command::ltrim(const std::string& list, Int64 start, Int64 stop)
{ {
Command cmd("LTRIM"); Command cmd("LTRIM");
@@ -332,6 +370,7 @@ Command Command::ltrim(const std::string& list, Int64 start, Int64 stop)
return cmd; return cmd;
} }
Command Command::mget(const StringVec& keys) Command Command::mget(const StringVec& keys)
{ {
Command cmd("MGET"); Command cmd("MGET");
@@ -341,6 +380,7 @@ Command Command::mget(const StringVec& keys)
return cmd; return cmd;
} }
Command Command::mset(const std::map<std::string, std::string>& keyvalues, bool create) Command Command::mset(const std::map<std::string, std::string>& keyvalues, bool create)
{ {
Command cmd(create ? "MSET" : "MSETNX"); Command cmd(create ? "MSET" : "MSETNX");
@@ -353,6 +393,7 @@ Command Command::mset(const std::map<std::string, std::string>& keyvalues, bool
return cmd; return cmd;
} }
Command Command::sadd(const std::string& set, const std::string& value) Command Command::sadd(const std::string& set, const std::string& value)
{ {
Command cmd("SADD"); Command cmd("SADD");
@@ -362,6 +403,7 @@ Command Command::sadd(const std::string& set, const std::string& value)
return cmd; return cmd;
} }
Command Command::sadd(const std::string& set, const StringVec& values) Command Command::sadd(const std::string& set, const StringVec& values)
{ {
Command cmd("SADD"); Command cmd("SADD");
@@ -371,6 +413,7 @@ Command Command::sadd(const std::string& set, const StringVec& values)
return cmd; return cmd;
} }
Command Command::scard(const std::string& set) Command Command::scard(const std::string& set)
{ {
Command cmd("SCARD"); Command cmd("SCARD");
@@ -380,6 +423,7 @@ Command Command::scard(const std::string& set)
return cmd; return cmd;
} }
Command Command::sdiff(const std::string& set1, const std::string& set2) Command Command::sdiff(const std::string& set1, const std::string& set2)
{ {
Command cmd("SDIFF"); Command cmd("SDIFF");
@@ -389,6 +433,7 @@ Command Command::sdiff(const std::string& set1, const std::string& set2)
return cmd; return cmd;
} }
Command Command::sdiff(const std::string& set, const StringVec& sets) Command Command::sdiff(const std::string& set, const StringVec& sets)
{ {
Command cmd("SDIFF"); Command cmd("SDIFF");
@@ -398,6 +443,7 @@ Command Command::sdiff(const std::string& set, const StringVec& sets)
return cmd; return cmd;
} }
Command Command::sdiffstore(const std::string& set, const std::string& set1, const std::string& set2) Command Command::sdiffstore(const std::string& set, const std::string& set1, const std::string& set2)
{ {
Command cmd("SDIFFSTORE"); Command cmd("SDIFFSTORE");
@@ -407,6 +453,7 @@ Command Command::sdiffstore(const std::string& set, const std::string& set1, con
return cmd; return cmd;
} }
Command Command::sdiffstore(const std::string& set, const StringVec& sets) Command Command::sdiffstore(const std::string& set, const StringVec& sets)
{ {
Command cmd("SDIFFSTORE"); Command cmd("SDIFFSTORE");
@@ -416,6 +463,7 @@ Command Command::sdiffstore(const std::string& set, const StringVec& sets)
return cmd; return cmd;
} }
Command Command::set(const std::string& key, const std::string& value, bool overwrite, const Poco::Timespan& expireTime, bool create) Command Command::set(const std::string& key, const std::string& value, bool overwrite, const Poco::Timespan& expireTime, bool create)
{ {
Command cmd("SET"); Command cmd("SET");
@@ -428,11 +476,13 @@ Command Command::set(const std::string& key, const std::string& value, bool over
return cmd; return cmd;
} }
Command Command::set(const std::string& key, Int64 value, bool overwrite, const Poco::Timespan& expireTime, bool create) Command Command::set(const std::string& key, Int64 value, bool overwrite, const Poco::Timespan& expireTime, bool create)
{ {
return set(key, NumberFormatter::format(value), overwrite, expireTime, create); return set(key, NumberFormatter::format(value), overwrite, expireTime, create);
} }
Command Command::sinter(const std::string& set1, const std::string& set2) Command Command::sinter(const std::string& set1, const std::string& set2)
{ {
Command cmd("SINTER"); Command cmd("SINTER");
@@ -442,6 +492,7 @@ Command Command::sinter(const std::string& set1, const std::string& set2)
return cmd; return cmd;
} }
Command Command::sinter(const std::string& set, const StringVec& sets) Command Command::sinter(const std::string& set, const StringVec& sets)
{ {
Command cmd("SINTER"); Command cmd("SINTER");
@@ -451,6 +502,7 @@ Command Command::sinter(const std::string& set, const StringVec& sets)
return cmd; return cmd;
} }
Command Command::sinterstore(const std::string& set, const std::string& set1, const std::string& set2) Command Command::sinterstore(const std::string& set, const std::string& set1, const std::string& set2)
{ {
Command cmd("SINTERSTORE"); Command cmd("SINTERSTORE");
@@ -460,6 +512,7 @@ Command Command::sinterstore(const std::string& set, const std::string& set1, co
return cmd; return cmd;
} }
Command Command::sinterstore(const std::string& set, const StringVec& sets) Command Command::sinterstore(const std::string& set, const StringVec& sets)
{ {
Command cmd("SINTERSTORE"); Command cmd("SINTERSTORE");
@@ -469,6 +522,7 @@ Command Command::sinterstore(const std::string& set, const StringVec& sets)
return cmd; return cmd;
} }
Command Command::sismember(const std::string& set, const std::string& member) Command Command::sismember(const std::string& set, const std::string& member)
{ {
Command cmd("SISMEMBER"); Command cmd("SISMEMBER");
@@ -478,6 +532,7 @@ Command Command::sismember(const std::string& set, const std::string& member)
return cmd; return cmd;
} }
Command Command::smembers(const std::string& set) Command Command::smembers(const std::string& set)
{ {
Command cmd("SMEMBERS"); Command cmd("SMEMBERS");
@@ -487,6 +542,7 @@ Command Command::smembers(const std::string& set)
return cmd; return cmd;
} }
Command Command::smove(const std::string& source, const std::string& destination, const std::string& member) Command Command::smove(const std::string& source, const std::string& destination, const std::string& member)
{ {
Command cmd("SMOVE"); Command cmd("SMOVE");
@@ -496,6 +552,7 @@ Command Command::smove(const std::string& source, const std::string& destination
return cmd; return cmd;
} }
Command Command::spop(const std::string& set, Int64 count) Command Command::spop(const std::string& set, Int64 count)
{ {
Command cmd("SPOP"); Command cmd("SPOP");
@@ -506,6 +563,7 @@ Command Command::spop(const std::string& set, Int64 count)
return cmd; return cmd;
} }
Command Command::srandmember(const std::string& set, Int64 count) Command Command::srandmember(const std::string& set, Int64 count)
{ {
Command cmd("SRANDMEMBER"); Command cmd("SRANDMEMBER");
@@ -516,6 +574,7 @@ Command Command::srandmember(const std::string& set, Int64 count)
return cmd; return cmd;
} }
Command Command::srem(const std::string& set1, const std::string& member) Command Command::srem(const std::string& set1, const std::string& member)
{ {
Command cmd("SREM"); Command cmd("SREM");
@@ -525,6 +584,7 @@ Command Command::srem(const std::string& set1, const std::string& member)
return cmd; return cmd;
} }
Command Command::srem(const std::string& set, const StringVec& members) Command Command::srem(const std::string& set, const StringVec& members)
{ {
Command cmd("SREM"); Command cmd("SREM");
@@ -534,6 +594,7 @@ Command Command::srem(const std::string& set, const StringVec& members)
return cmd; return cmd;
} }
Command Command::sunion(const std::string& set1, const std::string& set2) Command Command::sunion(const std::string& set1, const std::string& set2)
{ {
Command cmd("SUNION"); Command cmd("SUNION");
@@ -543,6 +604,7 @@ Command Command::sunion(const std::string& set1, const std::string& set2)
return cmd; return cmd;
} }
Command Command::sunion(const std::string& set, const StringVec& sets) Command Command::sunion(const std::string& set, const StringVec& sets)
{ {
Command cmd("SUNION"); Command cmd("SUNION");
@@ -552,6 +614,7 @@ Command Command::sunion(const std::string& set, const StringVec& sets)
return cmd; return cmd;
} }
Command Command::sunionstore(const std::string& set, const std::string& set1, const std::string& set2) Command Command::sunionstore(const std::string& set, const std::string& set1, const std::string& set2)
{ {
Command cmd("SUNIONSTORE"); Command cmd("SUNIONSTORE");
@@ -561,6 +624,7 @@ Command Command::sunionstore(const std::string& set, const std::string& set1, co
return cmd; return cmd;
} }
Command Command::sunionstore(const std::string& set, const StringVec& sets) Command Command::sunionstore(const std::string& set, const StringVec& sets)
{ {
Command cmd("SUNIONSTORE"); Command cmd("SUNIONSTORE");
@@ -570,6 +634,7 @@ Command Command::sunionstore(const std::string& set, const StringVec& sets)
return cmd; return cmd;
} }
Command Command::rename(const std::string& key, const std::string& newName, bool overwrite) Command Command::rename(const std::string& key, const std::string& newName, bool overwrite)
{ {
Command cmd(overwrite ? "RENAME" : "RENAMENX"); Command cmd(overwrite ? "RENAME" : "RENAMENX");
@@ -589,6 +654,7 @@ Command Command::rpop(const std::string& list)
return cmd; return cmd;
} }
Command Command::rpoplpush(const std::string& sourceList, const std::string& destinationList) Command Command::rpoplpush(const std::string& sourceList, const std::string& destinationList)
{ {
Command cmd("RPOPLPUSH"); Command cmd("RPOPLPUSH");
@@ -598,6 +664,7 @@ Command Command::rpoplpush(const std::string& sourceList, const std::string& des
return cmd; return cmd;
} }
Command Command::rpush(const std::string& list, const std::string& value, bool create) Command Command::rpush(const std::string& list, const std::string& value, bool create)
{ {
Command cmd(create ? "RPUSH" : "RPUSHX"); Command cmd(create ? "RPUSH" : "RPUSHX");
@@ -607,6 +674,7 @@ Command Command::rpush(const std::string& list, const std::string& value, bool c
return cmd; return cmd;
} }
Command Command::rpush(const std::string& list, const StringVec& values, bool create) Command Command::rpush(const std::string& list, const StringVec& values, bool create)
{ {
Command cmd(create ? "RPUSH" : "RPUSHX"); Command cmd(create ? "RPUSH" : "RPUSHX");
@@ -617,4 +685,4 @@ Command Command::rpush(const std::string& list, const StringVec& values, bool cr
} }
}} // Poco::Redis } } // namespace Poco::Redis

View File

@@ -9,27 +9,33 @@
// //
// Implementation of the Error class. // Implementation of the Error class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#include "Poco/Redis/Error.h" #include "Poco/Redis/Error.h"
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
Error::Error() Error::Error()
{ {
} }
Error::Error(const std::string& message): _message(message) Error::Error(const std::string& message): _message(message)
{ {
} }
Error::~Error() Error::~Error()
{ {
} }
} }
} } // namespace Poco::Redis

View File

@@ -9,17 +9,21 @@
// //
// Implementation of the Exception class. // Implementation of the Exception class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#include "Poco/Redis/Exception.h" #include "Poco/Redis/Exception.h"
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
POCO_IMPLEMENT_EXCEPTION(RedisException, Exception, "Redis Exception") POCO_IMPLEMENT_EXCEPTION(RedisException, Exception, "Redis Exception")
}}
} } // namespace Poco::Redis

View File

@@ -9,17 +9,20 @@
// //
// Implementation of the RedisEventArgs class. // Implementation of the RedisEventArgs class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#include "Poco/Redis/RedisEventArgs.h" #include "Poco/Redis/RedisEventArgs.h"
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
RedisEventArgs::RedisEventArgs(RedisType::Ptr pMessage): RedisEventArgs::RedisEventArgs(RedisType::Ptr pMessage):
_message(pMessage), _message(pMessage),
_exception(0), _exception(0),
@@ -27,6 +30,7 @@ RedisEventArgs::RedisEventArgs(RedisType::Ptr pMessage) :
{ {
} }
RedisEventArgs::RedisEventArgs(Exception* pException): RedisEventArgs::RedisEventArgs(Exception* pException):
_message(), _message(),
_exception(pException ? pException->clone() : 0), _exception(pException ? pException->clone() : 0),
@@ -34,6 +38,7 @@ RedisEventArgs::RedisEventArgs(Exception* pException) :
{ {
} }
RedisEventArgs::~RedisEventArgs() RedisEventArgs::~RedisEventArgs()
{ {
delete _exception; delete _exception;

View File

@@ -9,18 +9,26 @@
// //
// Implementation of the RedisStream class. // Implementation of the RedisStream class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#include <iostream>
#include "Poco/Redis/RedisStream.h" #include "Poco/Redis/RedisStream.h"
#include <iostream>
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
//
// RedisStreamBuf
//
RedisStreamBuf::RedisStreamBuf(Net::StreamSocket& redis): RedisStreamBuf::RedisStreamBuf(Net::StreamSocket& redis):
BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::in | std::ios::out), BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::in | std::ios::out),
_redis(redis) _redis(redis)
@@ -44,6 +52,12 @@ int RedisStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
return _redis.sendBytes(buffer, length); return _redis.sendBytes(buffer, length);
} }
//
// RedisIOS
//
RedisIOS::RedisIOS(Net::StreamSocket& redis): RedisIOS::RedisIOS(Net::StreamSocket& redis):
_buf(redis) _buf(redis)
{ {
@@ -74,6 +88,12 @@ void RedisIOS::close()
_buf.sync(); _buf.sync();
} }
//
// RedisOutputStream
//
RedisOutputStream::RedisOutputStream(Net::StreamSocket& redis): RedisOutputStream::RedisOutputStream(Net::StreamSocket& redis):
RedisIOS(redis), RedisIOS(redis),
std::ostream(&_buf) std::ostream(&_buf)
@@ -85,6 +105,7 @@ RedisOutputStream::~RedisOutputStream()
{ {
} }
RedisInputStream::RedisInputStream(Net::StreamSocket& redis): RedisInputStream::RedisInputStream(Net::StreamSocket& redis):
RedisIOS(redis), RedisIOS(redis),
std::istream(&_buf) std::istream(&_buf)
@@ -92,10 +113,16 @@ RedisInputStream::RedisInputStream(Net::StreamSocket& redis):
} }
//
// RedisInputStream
//
RedisInputStream::~RedisInputStream() RedisInputStream::~RedisInputStream()
{ {
} }
std::string RedisInputStream::getline() std::string RedisInputStream::getline()
{ {
std::string line; std::string line;
@@ -105,4 +132,4 @@ std::string RedisInputStream::getline()
} }
}} } } // namespace Poco::Redis

View File

@@ -9,16 +9,18 @@
// //
// Implementation of the Type class. // Implementation of the Type class.
// //
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#include "Poco/Redis/Type.h" #include "Poco/Redis/Type.h"
#include "Poco/Redis/Error.h" #include "Poco/Redis/Error.h"
#include "Poco/Redis/Array.h" #include "Poco/Redis/Array.h"
namespace Poco { namespace Poco {
namespace Redis { namespace Redis {
@@ -27,6 +29,7 @@ RedisType::RedisType()
{ {
} }
RedisType::~RedisType() RedisType::~RedisType()
{ {
} }
@@ -58,4 +61,4 @@ RedisType::Ptr RedisType::createRedisType(char marker)
} }
}} } } // namespace Poco::Redis

View File

@@ -5,7 +5,7 @@
// //
// Console-based test driver for Poco MongoDB. // Console-based test driver for Poco MongoDB.
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0

View File

@@ -3,24 +3,24 @@
// //
// $Id$ // $Id$
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
// //
#include <iostream>
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include "Poco/Delegate.h" #include "Poco/Delegate.h"
#include "Poco/Thread.h" #include "Poco/Thread.h"
#include "RedisTest.h" #include "RedisTest.h"
#include "Poco/Redis/AsyncReader.h" #include "Poco/Redis/AsyncReader.h"
#include "Poco/Redis/Command.h" #include "Poco/Redis/Command.h"
#include "Poco/Redis/PoolableConnectionFactory.h" #include "Poco/Redis/PoolableConnectionFactory.h"
#include "Poco/CppUnit/TestCaller.h" #include "Poco/CppUnit/TestCaller.h"
#include "Poco/CppUnit/TestSuite.h" #include "Poco/CppUnit/TestSuite.h"
#include <iostream>
using namespace Poco::Redis; using namespace Poco::Redis;
@@ -64,7 +64,6 @@ RedisTest::~RedisTest()
void RedisTest::setUp() void RedisTest::setUp()
{ {
} }
@@ -129,6 +128,7 @@ void RedisTest::testAPPEND()
} }
} }
void RedisTest::testBLPOP() void RedisTest::testBLPOP()
{ {
if (!_connected) if (!_connected)
@@ -185,6 +185,7 @@ void RedisTest::testBLPOP()
} }
} }
void RedisTest::testBRPOP() void RedisTest::testBRPOP()
{ {
if (!_connected) if (!_connected)
@@ -241,6 +242,7 @@ void RedisTest::testBRPOP()
} }
} }
void RedisTest::testDECR() void RedisTest::testDECR()
{ {
if (!_connected) if (!_connected)
@@ -294,6 +296,7 @@ void RedisTest::testDECR()
} }
void RedisTest::testECHO() void RedisTest::testECHO()
{ {
if (!_connected) if (!_connected)
@@ -318,6 +321,7 @@ void RedisTest::testECHO()
} }
} }
void RedisTest::testError() void RedisTest::testError()
{ {
if (!_connected) if (!_connected)
@@ -340,6 +344,7 @@ void RedisTest::testError()
} }
} }
void RedisTest::testEVAL() void RedisTest::testEVAL()
{ {
if (!_connected) if (!_connected)
@@ -375,6 +380,7 @@ void RedisTest::testEVAL()
} }
void RedisTest::testHDEL() void RedisTest::testHDEL()
{ {
if (!_connected) if (!_connected)
@@ -419,6 +425,7 @@ void RedisTest::testHDEL()
} }
} }
void RedisTest::testHEXISTS() void RedisTest::testHEXISTS()
{ {
if (!_connected) if (!_connected)
@@ -463,6 +470,7 @@ void RedisTest::testHEXISTS()
} }
} }
void RedisTest::testHGETALL() void RedisTest::testHGETALL()
{ {
if (!_connected) if (!_connected)
@@ -507,6 +515,7 @@ void RedisTest::testHGETALL()
} }
} }
void RedisTest::testHINCRBY() void RedisTest::testHINCRBY()
{ {
if (!_connected) if (!_connected)
@@ -562,6 +571,7 @@ void RedisTest::testHINCRBY()
} }
} }
void RedisTest::testHKEYS() void RedisTest::testHKEYS()
{ {
if (!_connected) if (!_connected)
@@ -619,6 +629,7 @@ void RedisTest::testHKEYS()
} }
} }
void RedisTest::testHMGET() void RedisTest::testHMGET()
{ {
if (!_connected) if (!_connected)
@@ -671,6 +682,7 @@ void RedisTest::testHMGET()
} }
} }
void RedisTest::testHSET() void RedisTest::testHSET()
{ {
if (!_connected) if (!_connected)
@@ -704,6 +716,7 @@ void RedisTest::testHSET()
} }
} }
void RedisTest::testHMSET() void RedisTest::testHMSET()
{ {
if (!_connected) if (!_connected)
@@ -753,6 +766,7 @@ void RedisTest::testHMSET()
} }
void RedisTest::testHSTRLEN() void RedisTest::testHSTRLEN()
{ {
if (!_connected) if (!_connected)
@@ -813,6 +827,7 @@ void RedisTest::testHSTRLEN()
} }
} }
void RedisTest::testHVALS() void RedisTest::testHVALS()
{ {
if (!_connected) if (!_connected)
@@ -852,6 +867,7 @@ void RedisTest::testHVALS()
} }
} }
void RedisTest::testINCR() void RedisTest::testINCR()
{ {
if (!_connected) if (!_connected)
@@ -884,6 +900,7 @@ void RedisTest::testINCR()
} }
} }
void RedisTest::testINCRBY() void RedisTest::testINCRBY()
{ {
if (!_connected) if (!_connected)
@@ -916,6 +933,7 @@ void RedisTest::testINCRBY()
} }
} }
void RedisTest::testPING() void RedisTest::testPING()
{ {
if (!_connected) if (!_connected)
@@ -953,6 +971,7 @@ void RedisTest::testPING()
} }
void RedisTest::testLPOP() void RedisTest::testLPOP()
{ {
if (!_connected) if (!_connected)
@@ -1014,6 +1033,7 @@ void RedisTest::testLPOP()
} }
void RedisTest::testLSET() void RedisTest::testLSET()
{ {
if (!_connected) if (!_connected)
@@ -1084,6 +1104,8 @@ void RedisTest::testLSET()
} }
} }
void RedisTest::testLINDEX() void RedisTest::testLINDEX()
{ {
if (!_connected) if (!_connected)
@@ -1122,6 +1144,7 @@ void RedisTest::testLINDEX()
} }
} }
void RedisTest::testLINSERT() void RedisTest::testLINSERT()
{ {
if (!_connected) if (!_connected)
@@ -1169,6 +1192,7 @@ void RedisTest::testLINSERT()
} }
} }
void RedisTest::testLREM() void RedisTest::testLREM()
{ {
if (!_connected) if (!_connected)
@@ -1230,6 +1254,7 @@ void RedisTest::testLREM()
} }
} }
void RedisTest::testLTRIM() void RedisTest::testLTRIM()
{ {
if (!_connected) if (!_connected)
@@ -1291,6 +1316,7 @@ void RedisTest::testLTRIM()
} }
void RedisTest::testMSET() void RedisTest::testMSET()
{ {
if (!_connected) if (!_connected)
@@ -1342,6 +1368,7 @@ void RedisTest::testMSET()
} }
} }
void RedisTest::testMSETWithMap() void RedisTest::testMSETWithMap()
{ {
if (!_connected) if (!_connected)
@@ -1397,6 +1424,7 @@ void RedisTest::testMSETWithMap()
} }
} }
void RedisTest::testMULTI() void RedisTest::testMULTI()
{ {
if (!_connected) if (!_connected)
@@ -1481,6 +1509,7 @@ void RedisTest::testMULTI()
} }
} }
void RedisTest::testPipeliningWithSendCommands() void RedisTest::testPipeliningWithSendCommands()
{ {
if (!_connected) if (!_connected)
@@ -1516,6 +1545,7 @@ void RedisTest::testPipeliningWithSendCommands()
} }
} }
void RedisTest::testPipeliningWithWriteCommand() void RedisTest::testPipeliningWithWriteCommand()
{ {
if (!_connected) if (!_connected)
@@ -1547,10 +1577,10 @@ void RedisTest::testPipeliningWithWriteCommand()
} }
} }
class RedisSubscriber class RedisSubscriber
{ {
public: public:
void onMessage(const void* pSender, RedisEventArgs& args) void onMessage(const void* pSender, RedisEventArgs& args)
{ {
if (!args.message().isNull()) if (!args.message().isNull())
@@ -1589,9 +1619,9 @@ public:
// No need to call stop, AsyncReader stops automatically when an // No need to call stop, AsyncReader stops automatically when an
// exception is received. // exception is received.
} }
}; };
void RedisTest::testPubSub() void RedisTest::testPubSub()
{ {
if (!_connected) if (!_connected)
@@ -1623,6 +1653,7 @@ void RedisTest::testPubSub()
_redis.flush(); _redis.flush();
} }
void RedisTest::testSADD() void RedisTest::testSADD()
{ {
if (!_connected) if (!_connected)
@@ -1667,6 +1698,7 @@ void RedisTest::testSADD()
} }
} }
void RedisTest::testSCARD() void RedisTest::testSCARD()
{ {
if (!_connected) if (!_connected)
@@ -1711,6 +1743,7 @@ void RedisTest::testSCARD()
} }
} }
void RedisTest::testSDIFF() void RedisTest::testSDIFF()
{ {
if (!_connected) if (!_connected)
@@ -1764,6 +1797,7 @@ void RedisTest::testSDIFF()
} }
} }
void RedisTest::testSDIFFSTORE() void RedisTest::testSDIFFSTORE()
{ {
if (!_connected) if (!_connected)
@@ -1829,6 +1863,7 @@ void RedisTest::testSDIFFSTORE()
} }
} }
void RedisTest::testSET() void RedisTest::testSET()
{ {
if (!_connected) if (!_connected)
@@ -1920,6 +1955,7 @@ void RedisTest::testSINTER()
} }
} }
void RedisTest::testSINTERSTORE() void RedisTest::testSINTERSTORE()
{ {
if (!_connected) if (!_connected)
@@ -1986,6 +2022,7 @@ void RedisTest::testSINTERSTORE()
} }
} }
void RedisTest::testSISMEMBER() void RedisTest::testSISMEMBER()
{ {
if (!_connected) if (!_connected)
@@ -2030,6 +2067,7 @@ void RedisTest::testSISMEMBER()
} }
} }
void RedisTest::testSMEMBERS() void RedisTest::testSMEMBERS()
{ {
if (!_connected) if (!_connected)
@@ -2074,6 +2112,7 @@ void RedisTest::testSMEMBERS()
} }
} }
void RedisTest::testSMOVE() void RedisTest::testSMOVE()
{ {
if (!_connected) if (!_connected)
@@ -2153,6 +2192,7 @@ void RedisTest::testSMOVE()
} }
} }
void RedisTest::testSPOP() void RedisTest::testSPOP()
{ {
if (!_connected) if (!_connected)
@@ -2254,6 +2294,7 @@ void RedisTest::testSPOP()
*/ */
} }
void RedisTest::testSRANDMEMBER() void RedisTest::testSRANDMEMBER()
{ {
if (!_connected) if (!_connected)
@@ -2314,6 +2355,7 @@ void RedisTest::testSRANDMEMBER()
} }
} }
void RedisTest::testSTRLEN() void RedisTest::testSTRLEN()
{ {
if (!_connected) if (!_connected)
@@ -2352,6 +2394,7 @@ void RedisTest::testSTRLEN()
} }
} }
void RedisTest::testSREM() void RedisTest::testSREM()
{ {
if (!_connected) if (!_connected)
@@ -2427,6 +2470,7 @@ void RedisTest::testSREM()
} }
} }
void RedisTest::testSUNION() void RedisTest::testSUNION()
{ {
if (!_connected) if (!_connected)
@@ -2480,6 +2524,7 @@ void RedisTest::testSUNION()
} }
} }
void RedisTest::testSUNIONSTORE() void RedisTest::testSUNIONSTORE()
{ {
if (!_connected) if (!_connected)
@@ -2545,6 +2590,7 @@ void RedisTest::testSUNIONSTORE()
} }
} }
void RedisTest::testRENAME() void RedisTest::testRENAME()
{ {
if (!_connected) if (!_connected)
@@ -2587,6 +2633,7 @@ void RedisTest::testRENAME()
} }
} }
void RedisTest::testRENAMENX() void RedisTest::testRENAMENX()
{ {
if (!_connected) if (!_connected)
@@ -2640,6 +2687,7 @@ void RedisTest::testRENAMENX()
} }
} }
void RedisTest::testRPOP() void RedisTest::testRPOP()
{ {
if (!_connected) if (!_connected)
@@ -2701,6 +2749,7 @@ void RedisTest::testRPOP()
} }
void RedisTest::testRPOPLPUSH() void RedisTest::testRPOPLPUSH()
{ {
if (!_connected) if (!_connected)
@@ -2793,6 +2842,7 @@ void RedisTest::testRPOPLPUSH()
} }
} }
void RedisTest::testRPUSH() void RedisTest::testRPUSH()
{ {
if (!_connected) if (!_connected)
@@ -2853,6 +2903,7 @@ void RedisTest::testRPUSH()
} }
} }
void RedisTest::testPool() void RedisTest::testPool()
{ {
Poco::Net::SocketAddress sa(_host, _port); Poco::Net::SocketAddress sa(_host, _port);
@@ -2875,6 +2926,7 @@ void RedisTest::testPool()
assert(keyValue.value().compare("Hello") == 0); assert(keyValue.value().compare("Hello") == 0);
} }
void RedisTest::delKey(const std::string& key) void RedisTest::delKey(const std::string& key)
{ {
Command delCommand = Command::del(key); Command delCommand = Command::del(key);
@@ -2951,7 +3003,6 @@ CppUnit::Test* RedisTest::suite()
CppUnit_addTest(pSuite, RedisTest, testRPOP); CppUnit_addTest(pSuite, RedisTest, testRPOP);
CppUnit_addTest(pSuite, RedisTest, testRPOPLPUSH); CppUnit_addTest(pSuite, RedisTest, testRPOPLPUSH);
CppUnit_addTest(pSuite, RedisTest, testRPUSH); CppUnit_addTest(pSuite, RedisTest, testRPUSH);
CppUnit_addTest(pSuite, RedisTest, testPool); CppUnit_addTest(pSuite, RedisTest, testPool);
return pSuite; return pSuite;

View File

@@ -5,7 +5,7 @@
// //
// Definition of the RedisTest class. // Definition of the RedisTest class.
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
@@ -18,7 +18,6 @@
#include "Poco/Redis/Redis.h" #include "Poco/Redis/Redis.h"
#include "Poco/Redis/Client.h" #include "Poco/Redis/Client.h"
#include "Poco/CppUnit/TestCase.h" #include "Poco/CppUnit/TestCase.h"

View File

@@ -3,7 +3,7 @@
// //
// $Id$ // $Id$
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0

View File

@@ -5,7 +5,7 @@
// //
// Definition of the RedisTestSuite class. // Definition of the RedisTestSuite class.
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0

View File

@@ -5,7 +5,7 @@
// //
// Console-based test driver for Windows CE. // Console-based test driver for Windows CE.
// //
// Copyright (c) 2004-2010, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0

View File

@@ -5,7 +5,7 @@
// //
// Windows test driver for Poco MongoDB. // Windows test driver for Poco MongoDB.
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0