database-redis.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. Minetest
  3. Copyright (C) 2014 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #pragma once
  17. #include "config.h"
  18. #if USE_REDIS
  19. #include <hiredis.h>
  20. #include <string>
  21. #include "database.h"
  22. class Settings;
  23. class Database_Redis : public MapDatabase
  24. {
  25. public:
  26. Database_Redis(Settings &conf);
  27. ~Database_Redis();
  28. void beginSave();
  29. void endSave();
  30. bool saveBlock(const v3s16 &pos, const std::string &data);
  31. void loadBlock(const v3s16 &pos, std::string *block);
  32. bool deleteBlock(const v3s16 &pos);
  33. void listAllLoadableBlocks(std::vector<v3s16> &dst);
  34. private:
  35. redisContext *ctx = nullptr;
  36. std::string hash = "";
  37. };
  38. #endif // USE_REDIS