6 #include <TKvsDatabase>
18 bool exists(
const QByteArray &key);
21 QByteArray get(
const QByteArray &key);
22 bool set(
const QByteArray &key,
const QByteArray &value);
23 bool setEx(
const QByteArray &key,
const QByteArray &value,
int seconds);
24 bool setNx(
const QByteArray &key,
const QByteArray &value);
25 QByteArray getSet(
const QByteArray &key,
const QByteArray &value);
28 QString gets(
const QByteArray &key);
29 bool sets(
const QByteArray &key,
const QString &value);
30 bool setsEx(
const QByteArray &key,
const QString &value,
int seconds);
31 bool setsNx(
const QByteArray &key,
const QString &value);
32 QString getsSets(
const QByteArray &key,
const QString &value);
34 bool del(
const QByteArray &key);
35 int del(
const QByteArrayList &keys);
38 int rpush(
const QByteArray &key,
const QByteArrayList &values);
39 int lpush(
const QByteArray &key,
const QByteArrayList &values);
40 QByteArrayList lrange(
const QByteArray &key,
int start,
int end);
41 QByteArray lindex(
const QByteArray &key,
int index);
44 int rpushs(
const QByteArray &key,
const QStringList &values);
45 int lpushs(
const QByteArray &key,
const QStringList &values);
46 QStringList lranges(
const QByteArray &key,
int start,
int end);
47 QString lindexs(
const QByteArray &key,
int index);
48 int llen(
const QByteArray &key);
51 bool hset(
const QByteArray &key,
const QByteArray &field,
const QByteArray &value);
52 bool hsetNx(
const QByteArray &key,
const QByteArray &field,
const QByteArray &value);
53 bool hsets(
const QByteArray &key,
const QByteArray &field,
const QString &value);
54 bool hsetsNx(
const QByteArray &key,
const QByteArray &field,
const QString &value);
55 QByteArray hget(
const QByteArray &key,
const QByteArray &field);
56 QString hgets(
const QByteArray &key,
const QByteArray &field);
57 bool hexists(
const QByteArray &key,
const QByteArray &field);
58 bool hdel(
const QByteArray &key,
const QByteArray &field);
59 int hdel(
const QByteArray &key,
const QByteArrayList &fields);
60 int hlen(
const QByteArray &key);
61 QList<QPair<QByteArray, QByteArray>> hgetAll(
const QByteArray &key);
67 TRedisDriver *driver();
68 const TRedisDriver *driver()
const;
70 static QByteArrayList toByteArrayList(
const QStringList &values);
71 static QStringList toStringList(
const QByteArrayList &values);
73 TKvsDatabase _database;
75 friend class TCacheRedisStore;
83 return QString::fromUtf8(
get(key));
86 inline bool TRedis::sets(
const QByteArray &key,
const QString &value)
88 return set(key, value.toUtf8());
91 inline bool TRedis::setsEx(
const QByteArray &key,
const QString &value,
int seconds)
93 return setEx(key, value.toUtf8(), seconds);
98 return setNx(key, value.toUtf8());
103 return QString::fromUtf8(
getSet(key, value.toUtf8()));
108 return rpush(key, toByteArrayList(values));
113 return lpush(key, toByteArrayList(values));
118 return toStringList(
lrange(key, start, end));
123 return QString::fromUtf8(
lindex(key, index));
126 inline bool TRedis::hsets(
const QByteArray &key,
const QByteArray &field,
const QString &value)
128 return hset(key, field, value.toUtf8());
131 inline bool TRedis::hsetsNx(
const QByteArray &key,
const QByteArray &field,
const QString &value)
133 return hsetNx(key, field, value.toUtf8());
136 inline QString
TRedis::hgets(
const QByteArray &key,
const QByteArray &field)
138 return QString::fromUtf8(
hget(key, field));
The TRedis class provides a means of operating a Redis system.
Definition: tredis.h:12
QString hgets(const QByteArray &key, const QByteArray &field)
Definition: tredis.h:136
QString gets(const QByteArray &key)
Returns the string associated with the key; otherwise returns a null string.
Definition: tredis.h:81
bool setNx(const QByteArray &key, const QByteArray &value)
Set the key to hold the value if key does not exist.
Definition: tredis.cpp:161
QByteArray getSet(const QByteArray &key, const QByteArray &value)
Atomically sets the key to the value and returns the old value stored at the key.
Definition: tredis.cpp:177
QString lindexs(const QByteArray &key, int index)
Returns the string at the index in the list stored at the key.
Definition: tredis.h:121
bool setsNx(const QByteArray &key, const QString &value)
Definition: tredis.h:96
int lpush(const QByteArray &key, const QByteArrayList &values)
Inserts all the values at the tail of the list stored at the key.
Definition: tredis.cpp:238
virtual ~TRedis()
Definition: tredis.h:15
bool hsets(const QByteArray &key, const QByteArray &field, const QString &value)
Definition: tredis.h:126
int lpushs(const QByteArray &key, const QStringList &values)
Inserts all the string values at the tail of the list stored at the key.
Definition: tredis.h:111
bool set(const QByteArray &key, const QByteArray &value)
Sets the key to hold the value.
Definition: tredis.cpp:130
QByteArray get(const QByteArray &key)
Returns the value associated with the key; otherwise returns an empty byte array.
Definition: tredis.cpp:114
QString getsSets(const QByteArray &key, const QString &value)
Atomically sets the key to the string value and returns the old string value stored at the key.
Definition: tredis.h:101
QStringList lranges(const QByteArray &key, int start, int end)
Returns the specified elements of the list stored at the key.
Definition: tredis.h:116
bool 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.
Definition: tredis.cpp:145
bool sets(const QByteArray &key, const QString &value)
Sets the key to hold the string value.
Definition: tredis.h:86
int rpushs(const QByteArray &key, const QStringList &values)
Inserts all the string values at the tail of the list stored at the key.
Definition: tredis.h:106
bool setsEx(const QByteArray &key, const QString &value, int seconds)
Sets the key to hold the string value and set the key to timeout after a given number of seconds.
Definition: tredis.h:91
bool hsetNx(const QByteArray &key, const QByteArray &field, const QByteArray &value)
Definition: tredis.cpp:336
int rpush(const QByteArray &key, const QByteArrayList &values)
Inserts all the values at the tail of the list stored at the key.
Definition: tredis.cpp:221
QByteArrayList lrange(const QByteArray &key, int start, int end)
Returns the specified elements of the list stored at the key.
Definition: tredis.cpp:254
bool hsetsNx(const QByteArray &key, const QByteArray &field, const QString &value)
Definition: tredis.h:131
QByteArray hget(const QByteArray &key, const QByteArray &field)
Definition: tredis.cpp:349
QByteArray lindex(const QByteArray &key, int index)
Returns the element at the index in the list stored at the key.
Definition: tredis.cpp:275
bool hset(const QByteArray &key, const QByteArray &field, const QByteArray &value)
Definition: tredis.cpp:323
KvsEngine
Definition: tfnamespace.h:239
#define T_CORE_EXPORT
Definition: tdeclexport.h:28
#define T_DISABLE_COPY(Class)
Definition: tdeclexport.h:37
#define T_DISABLE_MOVE(Class)
Definition: tdeclexport.h:41