#pragma once #include "db.h" #include #include #include #include class DBRedis : public DB { public: DBRedis(const std::string &mapdir); std::vector getBlockPos(BlockPos min, BlockPos max) override; void getBlocksOnXZ(BlockList &blocks, int16_t x, int16_t z, int16_t min_y, int16_t max_y) override; void getBlocksByPos(BlockList &blocks, const std::vector &positions) override; ~DBRedis() override; bool preferRangeQueries() const override { return false; } private: using pos2d = std::pair; static const char *replyTypeStr(int type); void loadPosCache(); void HMGET(const std::vector &positions, std::function result); // indexed by Z, contains all (x,y) position pairs std::unordered_map> posCache; redisContext *ctx; std::string hash; };