1
0
Fork 0
mirror of https://github.com/KingDuckZ/incredis synced 2024-11-27 00:43:50 +00:00

Add hmset and expire commands

This commit is contained in:
King_DuckZ 2017-04-25 00:08:17 +01:00
parent 1d7a89fee3
commit ac26d244a1
2 changed files with 15 additions and 0 deletions

View file

@ -70,6 +70,8 @@ namespace redis {
opt_string hget ( boost::string_ref parKey, boost::string_ref parField ); opt_string hget ( boost::string_ref parKey, boost::string_ref parField );
template <typename... Args> template <typename... Args>
opt_string_list hmget ( boost::string_ref parKey, Args&&... parArgs ); opt_string_list hmget ( boost::string_ref parKey, Args&&... parArgs );
template <typename... Args>
opt_string_list hmset ( boost::string_ref parKey, Args&&... parArgs );
int hincrby ( boost::string_ref parKey, boost::string_ref parField, int parInc ); int hincrby ( boost::string_ref parKey, boost::string_ref parField, int parInc );
//Set //Set
@ -86,6 +88,7 @@ namespace redis {
//Misc //Misc
bool flushdb ( void ); bool flushdb ( void );
RedisInt dbsize ( void ); RedisInt dbsize ( void );
bool expire ( boost::string_ref parKey, RedisInt parTTL );
//String //String
opt_string get ( boost::string_ref parKey ); opt_string get ( boost::string_ref parKey );
@ -103,6 +106,13 @@ namespace redis {
static_assert(sizeof...(Args) > 0, "No fields specified"); static_assert(sizeof...(Args) > 0, "No fields specified");
return reply_to_string_list(m_command.run("HMGET", parKey, std::forward<Args>(parArgs)...)); return reply_to_string_list(m_command.run("HMGET", parKey, std::forward<Args>(parArgs)...));
} }
template <typename... Args>
auto IncRedis::hmset (boost::string_ref parKey, Args&&... parArgs) -> opt_string_list {
static_assert(sizeof...(Args) > 0, "No fields specified");
static_assert(sizeof...(Args) % 2 == 0, "Uneven number of parameters received");
return reply_to_string_list(m_command.run("HMSET", parKey, std::forward<Args>(parArgs)...));
}
} //namespace redis } //namespace redis
#endif #endif

View file

@ -141,6 +141,11 @@ namespace redis {
return ret; return ret;
} }
bool IncRedis::expire (boost::string_ref parKey, RedisInt parTTL) {
const auto ret = redis::get<RedisInt>(m_command.run("EXPIRE", parKey, dhandy::lexical_cast<std::string>(parTTL)));
return (ret == 1 ? true : false);
}
auto IncRedis::reply_to_string_list (const Reply& parReply) -> opt_string_list { auto IncRedis::reply_to_string_list (const Reply& parReply) -> opt_string_list {
return optional_string_list(parReply); return optional_string_list(parReply);
} }