2013-06-30 02:34:10 +08:00
|
|
|
#ifndef QREDIS_CLIENT_H
|
|
|
|
|
#define QREDIS_CLIENT_H
|
|
|
|
|
|
2013-06-30 03:34:22 +08:00
|
|
|
#include <QHostAddress>
|
2013-06-30 02:34:10 +08:00
|
|
|
#include <QObject>
|
2013-06-30 03:04:01 +08:00
|
|
|
#include <QScopedPointer>
|
2013-06-30 02:34:10 +08:00
|
|
|
|
2013-06-30 03:04:01 +08:00
|
|
|
#include <qredis/command.h>
|
2013-06-30 02:34:10 +08:00
|
|
|
#include "qredis_export.h"
|
|
|
|
|
|
|
|
|
|
namespace QRedis
|
|
|
|
|
{
|
2013-06-30 03:04:01 +08:00
|
|
|
class QREDIS_EXPORT ClientPrivate;
|
|
|
|
|
|
|
|
|
|
/**
|
2013-06-30 03:34:22 +08:00
|
|
|
* @brief Provides access to a Redis server
|
2013-06-30 03:04:01 +08:00
|
|
|
*/
|
2013-06-30 02:34:10 +08:00
|
|
|
class QREDIS_EXPORT Client : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2013-06-30 03:04:01 +08:00
|
|
|
/**
|
2013-06-30 03:34:22 +08:00
|
|
|
* @brief Connects to a Redis server
|
2013-06-30 03:42:39 +08:00
|
|
|
* @param parent the parent QObject
|
2013-06-30 03:04:01 +08:00
|
|
|
*/
|
2013-06-30 03:42:39 +08:00
|
|
|
explicit Client(QObject * parent = nullptr);
|
2013-06-30 03:04:01 +08:00
|
|
|
|
|
|
|
|
/**
|
2013-06-30 03:34:22 +08:00
|
|
|
* @brief Disconnects from the Redis server
|
2013-06-30 03:04:01 +08:00
|
|
|
*/
|
2013-06-30 02:34:10 +08:00
|
|
|
virtual ~Client();
|
2013-06-30 03:04:01 +08:00
|
|
|
|
2013-06-30 03:34:22 +08:00
|
|
|
/**
|
|
|
|
|
* @brief Attempts to connect to the specified Redis server
|
|
|
|
|
* @param address the address of the Redis server
|
|
|
|
|
* @param port the port that the Redis server is listening on
|
|
|
|
|
*
|
|
|
|
|
* If the connection was successful, the connected() signal will be
|
|
|
|
|
* emitted.
|
|
|
|
|
*/
|
|
|
|
|
void connectToHost(const QHostAddress & address, quint16 port = 6379);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Disconnects from the Redis server
|
|
|
|
|
*/
|
2013-06-30 03:04:01 +08:00
|
|
|
void disconnectFromHost();
|
|
|
|
|
|
2013-06-30 03:34:22 +08:00
|
|
|
/**
|
|
|
|
|
* @brief Sends the specified command to the Redis server.
|
|
|
|
|
* @return an object that may be used for obtaining the response
|
|
|
|
|
*/
|
2013-06-30 03:04:01 +08:00
|
|
|
Command * sendCommand();
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
2013-06-30 03:34:22 +08:00
|
|
|
/**
|
|
|
|
|
* @brief Emitted when the client establishes a connection with the Redis server
|
|
|
|
|
*/
|
2013-06-30 03:04:01 +08:00
|
|
|
void connected();
|
|
|
|
|
|
2013-06-30 03:34:22 +08:00
|
|
|
/**
|
|
|
|
|
* @brief Emitted when the client disconnects from the Redis server
|
|
|
|
|
*/
|
|
|
|
|
void disconnected();
|
|
|
|
|
|
2013-06-30 03:04:01 +08:00
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
const QScopedPointer<ClientPrivate> d;
|
2013-06-30 02:34:10 +08:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-30 03:04:01 +08:00
|
|
|
#endif // QREDIS_CLIENT_H
|