TreeFrogFramework  2.8
Public Member Functions | Friends | List of all members
TRedis Class Reference

#include <tredis.h>

Public Member Functions

 TRedis ()
 
virtual ~TRedis ()
 
bool isOpen () const
 
bool exists (const QByteArray &key)
 
QByteArray get (const QByteArray &key)
 
bool set (const QByteArray &key, const QByteArray &value)
 
bool setEx (const QByteArray &key, const QByteArray &value, int seconds)
 
bool setNx (const QByteArray &key, const QByteArray &value)
 
QByteArray getSet (const QByteArray &key, const QByteArray &value)
 
QString gets (const QByteArray &key)
 
bool sets (const QByteArray &key, const QString &value)
 
bool setsEx (const QByteArray &key, const QString &value, int seconds)
 
bool setsNx (const QByteArray &key, const QString &value)
 
QString getsSets (const QByteArray &key, const QString &value)
 
bool del (const QByteArray &key)
 
int del (const QByteArrayList &keys)
 
int rpush (const QByteArray &key, const QByteArrayList &values)
 
int lpush (const QByteArray &key, const QByteArrayList &values)
 
QByteArrayList lrange (const QByteArray &key, int start, int end)
 
QByteArray lindex (const QByteArray &key, int index)
 
int rpushs (const QByteArray &key, const QStringList &values)
 
int lpushs (const QByteArray &key, const QStringList &values)
 
QStringList lranges (const QByteArray &key, int start, int end)
 
QString lindexs (const QByteArray &key, int index)
 
int llen (const QByteArray &key)
 
bool hset (const QByteArray &key, const QByteArray &field, const QByteArray &value)
 
bool hsetNx (const QByteArray &key, const QByteArray &field, const QByteArray &value)
 
bool hsets (const QByteArray &key, const QByteArray &field, const QString &value)
 
bool hsetsNx (const QByteArray &key, const QByteArray &field, const QString &value)
 
QByteArray hget (const QByteArray &key, const QByteArray &field)
 
QString hgets (const QByteArray &key, const QByteArray &field)
 
bool hexists (const QByteArray &key, const QByteArray &field)
 
bool hdel (const QByteArray &key, const QByteArray &field)
 
int hdel (const QByteArray &key, const QByteArrayList &fields)
 
int hlen (const QByteArray &key)
 
QList< QPair< QByteArray, QByteArray > > hgetAll (const QByteArray &key)
 
void flushDb ()
 

Friends

class TCacheRedisStore
 

Detailed Description

The TRedis class provides a means of operating a Redis system.

Edit conf/redis.ini and conf/application.ini to use this class.

redis.ini:

HostName=xxx.xxx.xxx.xxx
UserName=your_username
Password=your_password

application.ini:

@ RedisSettingsFile
Definition: tfnamespace.h:147

See also Redis documentation.

Constructor & Destructor Documentation

◆ TRedis()

TRedis::TRedis ( )

Constructs a TRedis object.

◆ ~TRedis()

virtual TRedis::~TRedis ( )
inlinevirtual

Member Function Documentation

◆ del() [1/2]

bool TRedis::del ( const QByteArray &  key)

Removes the specified key.

A key is ignored if it does not exist.

◆ del() [2/2]

int TRedis::del ( const QByteArrayList &  keys)

Removes the specified keys.

A key is ignored if it does not exist.

◆ exists()

bool TRedis::exists ( const QByteArray &  key)

Returns true if the key exists; otherwise returns false.

◆ flushDb()

void TRedis::flushDb ( )

◆ get()

QByteArray TRedis::get ( const QByteArray &  key)

Returns the value associated with the key; otherwise returns an empty byte array.

◆ gets()

QString TRedis::gets ( const QByteArray &  key)
inline

Returns the string associated with the key; otherwise returns a null string.

◆ getSet()

QByteArray TRedis::getSet ( const QByteArray &  key,
const QByteArray &  value 
)

Atomically sets the key to the value and returns the old value stored at the key.

◆ getsSets()

QString TRedis::getsSets ( const QByteArray &  key,
const QString &  value 
)
inline

Atomically sets the key to the string value and returns the old string value stored at the key.

◆ hdel() [1/2]

bool TRedis::hdel ( const QByteArray &  key,
const QByteArray &  field 
)

◆ hdel() [2/2]

int TRedis::hdel ( const QByteArray &  key,
const QByteArrayList &  fields 
)

◆ hexists()

bool TRedis::hexists ( const QByteArray &  key,
const QByteArray &  field 
)

◆ hget()

QByteArray TRedis::hget ( const QByteArray &  key,
const QByteArray &  field 
)

◆ hgetAll()

QList< QPair< QByteArray, QByteArray > > TRedis::hgetAll ( const QByteArray &  key)

◆ hgets()

QString TRedis::hgets ( const QByteArray &  key,
const QByteArray &  field 
)
inline

◆ hlen()

int TRedis::hlen ( const QByteArray &  key)

◆ hset()

bool TRedis::hset ( const QByteArray &  key,
const QByteArray &  field,
const QByteArray &  value 
)

◆ hsetNx()

bool TRedis::hsetNx ( const QByteArray &  key,
const QByteArray &  field,
const QByteArray &  value 
)

◆ hsets()

bool TRedis::hsets ( const QByteArray &  key,
const QByteArray &  field,
const QString &  value 
)
inline

◆ hsetsNx()

bool TRedis::hsetsNx ( const QByteArray &  key,
const QByteArray &  field,
const QString &  value 
)
inline

◆ isOpen()

bool TRedis::isOpen ( ) const

Returns true if the Redis connection is open; otherwise returns false.

◆ lindex()

QByteArray TRedis::lindex ( const QByteArray &  key,
int  index 
)

Returns the element at the index in the list stored at the key.

◆ lindexs()

QString TRedis::lindexs ( const QByteArray &  key,
int  index 
)
inline

Returns the string at the index in the list stored at the key.

◆ llen()

int TRedis::llen ( const QByteArray &  key)

Returns the length of the list stored at the key.

◆ lpush()

int TRedis::lpush ( const QByteArray &  key,
const QByteArrayList &  values 
)

Inserts all the values at the tail of the list stored at the key.

Returns the length of the list after the push operation.

◆ lpushs()

int TRedis::lpushs ( const QByteArray &  key,
const QStringList &  values 
)
inline

Inserts all the string values at the tail of the list stored at the key.

Returns the length of the list after the push operation.

◆ lrange()

QByteArrayList TRedis::lrange ( const QByteArray &  key,
int  start,
int  end = -1 
)

Returns the specified elements of the list stored at the key.

◆ lranges()

QStringList TRedis::lranges ( const QByteArray &  key,
int  start,
int  end = -1 
)
inline

Returns the specified elements of the list stored at the key.

◆ rpush()

int TRedis::rpush ( const QByteArray &  key,
const QByteArrayList &  values 
)

Inserts all the values at the tail of the list stored at the key.

Returns the length of the list after the push operation.

◆ rpushs()

int TRedis::rpushs ( const QByteArray &  key,
const QStringList &  values 
)
inline

Inserts all the string values at the tail of the list stored at the key.

Returns the length of the list after the push operation.

◆ set()

bool TRedis::set ( const QByteArray &  key,
const QByteArray &  value 
)

Sets the key to hold the value.

If the key already holds a value, it is overwritten, regardless of its type.

◆ setEx()

bool TRedis::setEx ( const QByteArray &  key,
const QByteArray &  value,
int  seconds 
)

Sets the key to hold the value and set the key to timeout after a given number of seconds.

◆ setNx()

bool TRedis::setNx ( const QByteArray &  key,
const QByteArray &  value 
)

Set the key to hold the value if key does not exist.

In that case, it is equal to SET. When key already holds a value, no operation is performed.

◆ sets()

bool TRedis::sets ( const QByteArray &  key,
const QString &  value 
)
inline

Sets the key to hold the string value.

If the key already holds a value, it is overwritten, regardless of its type.

◆ setsEx()

bool TRedis::setsEx ( const QByteArray &  key,
const QString &  value,
int  seconds 
)
inline

Sets the key to hold the string value and set the key to timeout after a given number of seconds.

◆ setsNx()

bool TRedis::setsNx ( const QByteArray &  key,
const QString &  value 
)
inline

Friends And Related Function Documentation

◆ TCacheRedisStore

friend class TCacheRedisStore
friend

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