qredisclient
Classes | Public Types | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Friends | List of all members
RedisClient::Connection Class Reference

The Connection class Main client class. More...

#include <connection.h>

Classes

class  InvalidModeException
 

Public Types

enum  Mode { Normal, PubSub, Cluster, Sentinel }
 
typedef QList< QByteArray > RawKeysList
 RawKeysList.
 
typedef std::function< void(const RawKeysList &, const QString &)> RawKeysListCallback
 
typedef QPair< QString, int > Host
 
typedef QList< Host > HostList
 
typedef std::function< void(QVariant, QString err)> CollectionCallback
 CollectionCallback.
 
typedef std::function< void(QVariant, QString err, bool final)> IncrementalCollectionCallback
 IncrementalCollectionCallback.
 

Signals

void addCommandToWorker (const Command &)
 
void error (const QString &)
 
void log (const QString &)
 
void connected ()
 
void disconnected ()
 
void authOk ()
 
void authError (const QString &)
 
void reconnectTo (const QString &host, int port)
 

Public Member Functions

 Connection (const ConnectionConfig &c, bool autoConnect=true)
 Constructs connection class. More...
 
virtual ~Connection ()
 ~Connection If connection established internally call disconnect()
 
virtual bool connect (bool wait=true)
 connects to redis-server More...
 
virtual bool isConnected ()
 isConnected More...
 
virtual void disconnect ()
 disconnect from redis-server
 
ConnectionConfig getConfig () const
 getConfig More...
 
void setConnectionConfig (const ConnectionConfig &)
 setConnectionConfig
 
Mode mode () const
 Get current mode. More...
 
virtual double getServerVersion ()
 Get redis-server version. More...
 
virtual DatabaseList getKeyspaceInfo ()
 Get keyspace info parsed from INFO command. More...
 
virtual void getDatabaseKeys (RawKeysListCallback callback, const QString &pattern=QString("*"), uint dbIndex=0)
 getDatabaseKeys - async keys loading More...
 
virtual void getClusterKeys (RawKeysListCallback callback, const QString &pattern)
 getClusterKeys - async keys loading from all cluster nodes More...
 
HostList getMasterNodes ()
 getMasterNodes - Get master nodes of cluster More...
 
void command (const Command &cmd)
 command More...
 
void command (QList< QByteArray > rawCmd, int db=-1)
 Execute command without callback in async mode. More...
 
void command (QList< QByteArray > rawCmd, QObject *owner, RedisClient::Command::Callback callback, int db=-1)
 Execute command with callback in async mode. More...
 
Response commandSync (const Command &cmd)
 commandSync More...
 
Response commandSync (QList< QByteArray > rawCmd, int db=-1)
 Execute command without callback and wait for response. More...
 
Response commandSync (QString cmd, int db=-1)
 
Response commandSync (QString cmd, QString arg1, int db=-1)
 
Response commandSync (QString cmd, QString arg1, QString arg2, int db=-1)
 
Response commandSync (QString cmd, QString arg1, QString arg2, QString arg3, int db=-1)
 
virtual void retrieveCollection (QSharedPointer< ScanCommand > cmd, CollectionCallback callback)
 retrieveCollection More...
 
virtual void retrieveCollectionIncrementally (QSharedPointer< ScanCommand > cmd, IncrementalCollectionCallback callback)
 retrieveCollection More...
 
virtual void runCommand (const Command &cmd)
 runCommand - Low level commands execution API More...
 
bool waitForIdle (uint timeout)
 waitForIdle - Wait until all commands in queue will be processed More...
 
void setTransporter (QSharedPointer< AbstractTransporter >)
 
QSharedPointer< AbstractTransporter > getTransporter () const
 

Protected Slots

void auth ()
 

Protected Member Functions

void createTransporter ()
 
bool isTransporterRunning ()
 
Response internalCommandSync (QList< QByteArray > rawCmd)
 
void processScanCommand (QSharedPointer< ScanCommand > cmd, CollectionCallback callback, QSharedPointer< QVariantList > result=QSharedPointer< QVariantList >(), bool incrementalProcessing=false)
 
void changeCurrentDbNumber (int db)
 

Protected Attributes

ConnectionConfig m_config
 
QSharedPointer< QThread > m_transporterThread
 
QSharedPointer< AbstractTransporter > m_transporter
 
int m_dbNumber
 
ServerInfo m_serverInfo
 
Mode m_currentMode
 
QMutex m_dbNumberMutex
 
bool m_autoConnect
 
bool m_stoppingTransporter
 
RawKeysListCallback m_wrapper
 

Friends

class AbstractTransporter
 

Detailed Description

The Connection class Main client class.

Inheritance diagram for RedisClient::Connection:

Constructor & Destructor Documentation

RedisClient::Connection::Connection ( const ConnectionConfig c,
bool  autoConnect = true 
)

Constructs connection class.

Parameters
c- connection config NOTE: different config options are required for different transporters.

Member Function Documentation

void RedisClient::Connection::command ( const Command cmd)

command

Parameters
cmd
void RedisClient::Connection::command ( QList< QByteArray >  rawCmd,
int  db = -1 
)

Execute command without callback in async mode.

Parameters
rawCmd
db
void RedisClient::Connection::command ( QList< QByteArray >  rawCmd,
QObject *  owner,
RedisClient::Command::Callback  callback,
int  db = -1 
)

Execute command with callback in async mode.

Parameters
rawCmd
owner
callback
db
RedisClient::Response RedisClient::Connection::commandSync ( const Command cmd)

commandSync

Parameters
cmd
Returns
RedisClient::Response RedisClient::Connection::commandSync ( QList< QByteArray >  rawCmd,
int  db = -1 
)

Execute command without callback and wait for response.

Parameters
rawCmd
db
Returns
bool RedisClient::Connection::connect ( bool  wait = true)
virtual

connects to redis-server

Parameters
wait- true = sync mode, false = async mode
Returns
true - on success
Exceptions
Connection::Exceptionif config is invalid or something went wrong.
void RedisClient::Connection::getClusterKeys ( RawKeysListCallback  callback,
const QString &  pattern 
)
virtual

getClusterKeys - async keys loading from all cluster nodes

Parameters
callback
pattern
RedisClient::ConnectionConfig RedisClient::Connection::getConfig ( ) const

getConfig

Returns
void RedisClient::Connection::getDatabaseKeys ( RawKeysListCallback  callback,
const QString &  pattern = QString("*"),
uint  dbIndex = 0 
)
virtual

getDatabaseKeys - async keys loading

Parameters
callback
pattern
dbIndex
RedisClient::DatabaseList RedisClient::Connection::getKeyspaceInfo ( )
virtual

Get keyspace info parsed from INFO command.

Returns
RedisClient::Connection::HostList RedisClient::Connection::getMasterNodes ( )

getMasterNodes - Get master nodes of cluster

Returns
HostList
double RedisClient::Connection::getServerVersion ( )
virtual

Get redis-server version.

Returns
bool RedisClient::Connection::isConnected ( )
virtual

isConnected

Returns
RedisClient::Connection::Mode RedisClient::Connection::mode ( ) const

Get current mode.

Returns
void RedisClient::Connection::retrieveCollection ( QSharedPointer< ScanCommand cmd,
CollectionCallback  callback 
)
virtual

retrieveCollection

Parameters
cmd
callback
void RedisClient::Connection::retrieveCollectionIncrementally ( QSharedPointer< ScanCommand cmd,
IncrementalCollectionCallback  callback 
)
virtual

retrieveCollection

Parameters
cmd
callback
void RedisClient::Connection::runCommand ( const Command cmd)
virtual

runCommand - Low level commands execution API

Parameters
cmd
bool RedisClient::Connection::waitForIdle ( uint  timeout)

waitForIdle - Wait until all commands in queue will be processed

Parameters
timeout- in milliseconds

The documentation for this class was generated from the following files: