mirror of
https://github.com/KingDuckZ/incredis
synced 2025-08-11 13:09:48 +00:00
Add set/get/flushdb/dbsize convenience methods.
This commit is contained in:
parent
68a73d3eb6
commit
20edb06241
5 changed files with 77 additions and 2 deletions
|
@ -127,11 +127,33 @@ namespace redis {
|
|||
}
|
||||
|
||||
bool IncRedis::script_flush() {
|
||||
const auto ret = get<StatusString>(m_command.run("SCRIPT", "FLUSH"));
|
||||
const auto ret = redis::get<StatusString>(m_command.run("SCRIPT", "FLUSH"));
|
||||
return ret.is_ok();
|
||||
}
|
||||
|
||||
bool IncRedis::flushdb() {
|
||||
const auto ret = redis::get<StatusString>(m_command.run("FLUSHDB"));
|
||||
return ret.is_ok();
|
||||
}
|
||||
|
||||
RedisInt IncRedis::dbsize() {
|
||||
const auto ret = redis::get<RedisInt>(m_command.run("DBSIZE"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto IncRedis::reply_to_string_list (const Reply& parReply) -> opt_string_list {
|
||||
return optional_string_list(parReply);
|
||||
}
|
||||
|
||||
auto IncRedis::get (boost::string_ref parKey) -> opt_string {
|
||||
return optional_string(m_command.run("GET", parKey));
|
||||
}
|
||||
|
||||
bool IncRedis::set (boost::string_ref parKey, boost::string_ref parField) {
|
||||
auto batch = make_batch();
|
||||
batch.set(parKey, parField, IncRedisBatch::ADD_None);
|
||||
assert(batch.replies().size() == 1);
|
||||
const auto ret = redis::get<StatusString>(batch.replies().front());
|
||||
return ret.is_ok();
|
||||
}
|
||||
} //namespace redis
|
||||
|
|
|
@ -74,6 +74,21 @@ namespace redis {
|
|||
return *this;
|
||||
}
|
||||
|
||||
IncRedisBatch& IncRedisBatch::set (boost::string_ref parKey, boost::string_ref parField, ADD_Mode parMode) {
|
||||
switch(parMode) {
|
||||
case ADD_None:
|
||||
m_batch.run("SET", parKey, parField);
|
||||
break;
|
||||
case ADD_NX:
|
||||
m_batch.run("SET", parKey, parField, "NX");
|
||||
break;
|
||||
case ADD_XX:
|
||||
m_batch.run("SET", parKey, parField, "XX");
|
||||
break;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
IncRedisBatch& IncRedisBatch::zrangebyscore (boost::string_ref parKey, double parMin, bool parMinIncl, double parMax, bool parMaxIncl, bool parWithScores) {
|
||||
auto lower_bound = make_boundary(parMin, not parMinIncl);
|
||||
auto upper_bound = make_boundary(parMax, not parMaxIncl);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue