mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-15 16:14:12 +00:00
New ScanIterator class.
Not yet tested and only supporting the SCAN command for now, more to come. Also includes some refactoring that was needed to make everything work.
This commit is contained in:
parent
04b667485e
commit
c1e79c435b
10 changed files with 423 additions and 48 deletions
|
@ -19,47 +19,26 @@
|
|||
#define idD83EEBFC927840C6B9F32D61A1D1E582
|
||||
|
||||
#include "arg_to_bin_safe.hpp"
|
||||
#include "scan_iterator.hpp"
|
||||
#include "reply.hpp"
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cassert>
|
||||
#include <boost/variant/variant.hpp>
|
||||
#include <boost/variant/recursive_wrapper.hpp>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
|
||||
struct redisContext;
|
||||
|
||||
namespace redis {
|
||||
class RedisReplyType;
|
||||
|
||||
namespace implem {
|
||||
using RedisVariantType = boost::variant<
|
||||
long long,
|
||||
std::string,
|
||||
boost::recursive_wrapper<std::vector<RedisReplyType>>
|
||||
>;
|
||||
enum RedisVariantTypes {
|
||||
RedisVariantType_Integer = 0,
|
||||
RedisVariantType_String,
|
||||
RedisVariantType_Array
|
||||
};
|
||||
} //namespace implem
|
||||
|
||||
struct RedisReplyType : implem::RedisVariantType {
|
||||
using base_class = implem::RedisVariantType;
|
||||
|
||||
RedisReplyType ( void ) = default;
|
||||
RedisReplyType ( long long parVal ) : base_class(parVal) {}
|
||||
RedisReplyType ( std::string&& parVal ) : base_class(std::move(parVal)) {}
|
||||
RedisReplyType ( std::vector<RedisReplyType>&& parVal ) : base_class(std::move(parVal)) {}
|
||||
~RedisReplyType ( void ) noexcept = default;
|
||||
};
|
||||
|
||||
class Command {
|
||||
public:
|
||||
typedef ScanIterator<std::string, ScanSingleValues<std::string>> scan_iterator;
|
||||
typedef boost::iterator_range<scan_iterator> scan_range;
|
||||
|
||||
Command ( std::string&& parAddress, uint16_t parPort );
|
||||
~Command ( void ) noexcept;
|
||||
|
||||
|
@ -71,6 +50,9 @@ namespace redis {
|
|||
template <typename... Args>
|
||||
RedisReplyType run ( const char* parCommand, Args&&... parArgs );
|
||||
|
||||
//Single Redis command wrappers
|
||||
scan_range scan ( void );
|
||||
|
||||
private:
|
||||
using RedisConnection = std::unique_ptr<redisContext, void(*)(redisContext*)>;
|
||||
|
||||
|
@ -87,10 +69,6 @@ namespace redis {
|
|||
using CharPointerArray = std::array<const char*, arg_count>;
|
||||
using LengthArray = std::array<std::size_t, arg_count>;
|
||||
|
||||
CharPointerArray arguments;
|
||||
LengthArray lengths;
|
||||
assert(false); //TODO write implementation
|
||||
|
||||
return this->run_pvt(
|
||||
parCommand,
|
||||
static_cast<int>(arg_count),
|
||||
|
@ -98,10 +76,6 @@ namespace redis {
|
|||
LengthArray{ implem::arg_to_bin_safe_length(std::forward<Args>(parArgs))... }.data()
|
||||
);
|
||||
}
|
||||
|
||||
long long get_integer ( const RedisReplyType& parReply );
|
||||
std::string get_string ( const RedisReplyType& parReply );
|
||||
std::vector<RedisReplyType> get_array ( const RedisReplyType& parReply );
|
||||
} //namespace redis
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue