From 83bc362dacfdef2bdf18cae5e2c52f526e8431c5 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 26 May 2024 14:28:30 +0200 Subject: [PATCH] Mark Redis database backend as deprecated (#14679) --- src/database/database-redis.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/database/database-redis.cpp b/src/database/database-redis.cpp index a9e549c33..a9a4a37f1 100644 --- a/src/database/database-redis.cpp +++ b/src/database/database-redis.cpp @@ -32,6 +32,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include +#if VERSION_MAJOR > 5 || VERSION_MINOR > 9 +#define DEPRECATION_PERIOD_OVER +#endif Database_Redis::Database_Redis(Settings &conf) { @@ -66,6 +69,14 @@ Database_Redis::Database_Redis(Settings &conf) } 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() @@ -73,16 +84,22 @@ Database_Redis::~Database_Redis() 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(redisCommand(ctx, "MULTI")); if (!reply) { throw DatabaseException(std::string( "Redis command 'MULTI' failed: ") + ctx->errstr); } freeReplyObject(reply); +#endif } -void Database_Redis::endSave() { +void Database_Redis::endSave() +{ redisReply *reply = static_cast(redisCommand(ctx, "EXEC")); if (!reply) { throw DatabaseException(std::string(