mirror of
https://github.com/luanti-org/minetestmapper.git
synced 2025-10-06 05:45:21 +02:00
Rewrite DB class to allow backends to fully optimize block fetches
This commit is contained in:
@@ -2,21 +2,27 @@
|
||||
#define DB_REDIS_HEADER
|
||||
|
||||
#include "db.h"
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <hiredis/hiredis.h>
|
||||
|
||||
class DBRedis : public DB {
|
||||
public:
|
||||
DBRedis(const std::string &mapdir);
|
||||
virtual std::vector<BlockPos> getBlockPos();
|
||||
virtual void getBlocksOnZ(std::map<int16_t, BlockList> &blocks, int16_t zPos);
|
||||
virtual ~DBRedis();
|
||||
std::vector<BlockPos> 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;
|
||||
~DBRedis() override;
|
||||
|
||||
private:
|
||||
using pos2d = std::pair<int16_t, int16_t>;
|
||||
static std::string replyTypeStr(int type);
|
||||
|
||||
void loadPosCache();
|
||||
void HMGET(const std::vector<BlockPos> &positions, std::vector<ustring> *result);
|
||||
|
||||
std::vector<BlockPos> posCache;
|
||||
// indexed by Z, contains all (x,y) position pairs
|
||||
std::unordered_map<int16_t, std::vector<pos2d>> posCache;
|
||||
|
||||
redisContext *ctx;
|
||||
std::string hash;
|
||||
|
Reference in New Issue
Block a user