- Update documentation for using "SET ... EX" in Redis.

- Document max buffer sizes for Redis commands.
This commit is contained in:
Yorgos Thessalonikefs 2025-09-08 14:49:12 +02:00
parent 5588f66bdb
commit a72177e73c
3 changed files with 21 additions and 4 deletions

View 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);

View 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.

View 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