mirror of
https://github.com/minetest/minetest.git
synced 2025-03-22 10:12:32 +01:00
Mark Redis database backend as deprecated (#14679)
This commit is contained in:
@ -32,6 +32,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <hiredis.h>
|
#include <hiredis.h>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
#if VERSION_MAJOR > 5 || VERSION_MINOR > 9
|
||||||
|
#define DEPRECATION_PERIOD_OVER
|
||||||
|
#endif
|
||||||
|
|
||||||
Database_Redis::Database_Redis(Settings &conf)
|
Database_Redis::Database_Redis(Settings &conf)
|
||||||
{
|
{
|
||||||
@ -66,6 +69,14 @@ Database_Redis::Database_Redis(Settings &conf)
|
|||||||
}
|
}
|
||||||
freeReplyObject(reply);
|
freeReplyObject(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
warningstream << "/!\\ You are using the deprecated redis backend. "
|
||||||
|
#ifdef DEPRECATION_PERIOD_OVER
|
||||||
|
<< "This backend is only still supported for migrations. /!\\\n"
|
||||||
|
#else
|
||||||
|
<< "This backend will become read-only in the next release. /!\\\n"
|
||||||
|
#endif
|
||||||
|
<< "Please migrate to SQLite3 or PostgreSQL instead." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Database_Redis::~Database_Redis()
|
Database_Redis::~Database_Redis()
|
||||||
@ -73,16 +84,22 @@ Database_Redis::~Database_Redis()
|
|||||||
redisFree(ctx);
|
redisFree(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database_Redis::beginSave() {
|
void Database_Redis::beginSave()
|
||||||
|
{
|
||||||
|
#ifdef DEPRECATION_PERIOD_OVER
|
||||||
|
throw DatabaseException("Redis backend is read-only, see deprecation notice.");
|
||||||
|
#else
|
||||||
redisReply *reply = static_cast<redisReply *>(redisCommand(ctx, "MULTI"));
|
redisReply *reply = static_cast<redisReply *>(redisCommand(ctx, "MULTI"));
|
||||||
if (!reply) {
|
if (!reply) {
|
||||||
throw DatabaseException(std::string(
|
throw DatabaseException(std::string(
|
||||||
"Redis command 'MULTI' failed: ") + ctx->errstr);
|
"Redis command 'MULTI' failed: ") + ctx->errstr);
|
||||||
}
|
}
|
||||||
freeReplyObject(reply);
|
freeReplyObject(reply);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database_Redis::endSave() {
|
void Database_Redis::endSave()
|
||||||
|
{
|
||||||
redisReply *reply = static_cast<redisReply *>(redisCommand(ctx, "EXEC"));
|
redisReply *reply = static_cast<redisReply *>(redisCommand(ctx, "EXEC"));
|
||||||
if (!reply) {
|
if (!reply) {
|
||||||
throw DatabaseException(std::string(
|
throw DatabaseException(std::string(
|
||||||
|
Reference in New Issue
Block a user