mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-04 14:24:10 +00:00
New wrapper methods.
This commit is contained in:
parent
e0670ff433
commit
f4c495c5ea
4 changed files with 55 additions and 0 deletions
|
@ -24,23 +24,37 @@
|
|||
namespace redis {
|
||||
class IncRedisBatch {
|
||||
public:
|
||||
IncRedisBatch ( void ) = delete;
|
||||
IncRedisBatch ( IncRedisBatch&& ) = default;
|
||||
IncRedisBatch ( const Batch& ) = delete;
|
||||
IncRedisBatch ( Batch&& parBatch );
|
||||
|
||||
void reset ( void );
|
||||
void throw_if_failed ( void );
|
||||
const std::vector<Reply>& replies ( void ) { return m_batch.replies(); }
|
||||
Batch& batch ( void ) { return m_batch; }
|
||||
const Batch& batch ( void ) const { return m_batch; }
|
||||
|
||||
//Misc
|
||||
IncRedisBatch& select ( int parIndex );
|
||||
IncRedisBatch& client_setname ( boost::string_ref parName );
|
||||
template <typename... Args>
|
||||
IncRedisBatch& del ( Args&&... parArgs );
|
||||
|
||||
//Hash
|
||||
IncRedisBatch& hget ( boost::string_ref parKey, boost::string_ref parField );
|
||||
template <typename... Args>
|
||||
IncRedisBatch& hmget ( boost::string_ref parKey, Args&&... parArgs );
|
||||
template <typename... Args>
|
||||
IncRedisBatch& hmset ( boost::string_ref parKey, Args&&... parArgs );
|
||||
IncRedisBatch& hincrby ( boost::string_ref parKey, boost::string_ref parField, int parInc );
|
||||
|
||||
//Set
|
||||
IncRedisBatch& srandmember ( boost::string_ref parKey, int parCount );
|
||||
IncRedisBatch& srandmember ( boost::string_ref parKey );
|
||||
template <typename... Args>
|
||||
IncRedisBatch& sadd ( boost::string_ref parKey, Args&&... parArgs );
|
||||
|
||||
//Script
|
||||
IncRedisBatch& script_flush ( void );
|
||||
|
||||
|
@ -50,9 +64,31 @@ namespace redis {
|
|||
|
||||
template <typename... Args>
|
||||
IncRedisBatch& IncRedisBatch::hmget (boost::string_ref parKey, Args&&... parArgs) {
|
||||
static_assert(sizeof...(Args) > 0, "No fields specified");
|
||||
m_batch.run("HMGET", parKey, std::forward<Args>(parArgs)...);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
IncRedisBatch& IncRedisBatch::hmset (boost::string_ref parKey, Args&&... parArgs) {
|
||||
static_assert(sizeof...(Args) % 2 == 0, "Uneven number of parameters received");
|
||||
m_batch.run("HMSET", parKey, std::forward<Args>(parArgs)...);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
IncRedisBatch& IncRedisBatch::sadd (boost::string_ref parKey, Args&&... parArgs) {
|
||||
static_assert(sizeof...(Args) > 0, "No members specified");
|
||||
m_batch.run("SADD", parKey, std::forward<Args>(parArgs)...);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
IncRedisBatch& IncRedisBatch::del (Args&&... parArgs) {
|
||||
static_assert(sizeof...(Args) > 0, "No keys specified");
|
||||
m_batch.run("DEL", std::forward<Args>(parArgs)...);
|
||||
return *this;
|
||||
}
|
||||
} //namespace redis
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue