]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Update documentation for using "SET ... EX" in Redis.
authorYorgos Thessalonikefs <yorgos@nlnetlabs.nl>
Mon, 8 Sep 2025 12:49:12 +0000 (14:49 +0200)
committerYorgos Thessalonikefs <yorgos@nlnetlabs.nl>
Mon, 8 Sep 2025 12:49:12 +0000 (14:49 +0200)
- Document max buffer sizes for Redis commands.

cachedb/redis.c
doc/Changelog
doc/unbound.conf.rst

index 80e24c78fe4db3ee859912d585216653ab37a056..9383f1c8576c845d87a91d9bc31c36d738e82ae8 100644 (file)
@@ -392,7 +392,7 @@ redis_init(struct module_env* env, struct cachedb_env* cachedb_env)
 set_with_ex_fail:
        log_err("redis_init: failure during redis_init, the "
                "redis-expire-records option requires the SET with EX command "
-               "(redis >= 2.6.2)");
+               "(redis >= 2.6.12)");
        return 1;
 fail:
        moddata_clean(&moddata);
@@ -508,7 +508,14 @@ redis_lookup(struct module_env* env, struct cachedb_env* cachedb_env,
        char* key, struct sldns_buffer* result_buffer)
 {
        redisReply* rep;
-       char cmdbuf[4+(CACHEDB_HASHSIZE/8)*2+1]; /* "GET " + key */
+       /* Supported commands:
+        * - "GET " + key
+        */
+#define REDIS_LOOKUP_MAX_BUF_LEN                       \
+       4                               /* "GET " */    \
+       +(CACHEDB_HASHSIZE/8)*2         /* key hash */  \
+       + 1                             /* \0 */
+       char cmdbuf[REDIS_LOOKUP_MAX_BUF_LEN];
        int n;
        int ret = 0;
 
@@ -568,7 +575,13 @@ redis_store(struct module_env* env, struct cachedb_env* cachedb_env,
         *   older redis 2.0.0 was "SETEX " + key + " " + ttl + " %b"
         * - "EXPIRE " + key + " 0"
         */
-       char cmdbuf[6+(CACHEDB_HASHSIZE/8)*2+11+3+1];
+#define REDIS_STORE_MAX_BUF_LEN                                \
+       7                       /* "EXPIRE " */         \
+       +(CACHEDB_HASHSIZE/8)*2 /* key hash */          \
+       + 7                     /* " %b EX " */         \
+       + 20                    /* ttl (uint64_t) */    \
+       + 1                     /* \0 */
+       char cmdbuf[REDIS_STORE_MAX_BUF_LEN];
 
        if (!set_ttl) {
                verbose(VERB_ALGO, "redis_store %s (%d bytes)", key, (int)data_len);
index fd955ba8907f3a32f971aa9682c5c5ef092544af..ff995b16d1a06be6aac5c0dd7225d18a708e9295 100644 (file)
@@ -1,3 +1,7 @@
+8 September 2025: Yorgos
+       - Update documentation for using "SET ... EX" in Redis.
+       - Document max buffer sizes for Redis commands.
+
 3 September 2025: Wouter
        - For #1328: make depend.
 
index c6cc91387fe2de461cceb8455829cc8f6d4eb413..ad8404e113cf28793f0e2a7fe6891d6d1c4abf89 100644 (file)
@@ -4495,7 +4495,7 @@ The following **cachedb:** options are specific to the ``redis`` backend.
     internally reverted to "no".
 
     .. note::
-        Redis SETEX support is required for this option (Redis >= 2.0.0).
+        Redis "SET ... EX" support is required for this option (Redis >= 2.6.12).
 
     Default: no