summaryrefslogtreecommitdiff
path: root/examples/redis-unstable/modules/vector-sets/vset_config.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/redis-unstable/modules/vector-sets/vset_config.c')
-rw-r--r--examples/redis-unstable/modules/vector-sets/vset_config.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/examples/redis-unstable/modules/vector-sets/vset_config.c b/examples/redis-unstable/modules/vector-sets/vset_config.c
new file mode 100644
index 0000000..79dc8a3
--- /dev/null
+++ b/examples/redis-unstable/modules/vector-sets/vset_config.c
@@ -0,0 +1,51 @@
1/* vector set module configuration.
2 *
3 * Copyright (c) 2009-Present, Redis Ltd.
4 * All rights reserved.
5 *
6 * Licensed under your choice of (a) the Redis Source Available License 2.0
7 * (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the
8 * GNU Affero General Public License v3 (AGPLv3).
9*/
10
11#include "vset_config.h"
12
13/* Define __STRING macro for portability (not available in all environments) */
14#ifndef __STRING
15#define __STRING(x) #x
16#endif
17
18#define RM_TRY(expr) \
19 if (expr == REDISMODULE_ERR) { \
20 RedisModule_Log(ctx, "warning", "Could not run " __STRING(expr)); \
21 return REDISMODULE_ERR; \
22 }
23
24VSConfig VSGlobalConfig;
25
26int set_bool_config(const char *name, int val, void *privdata,
27 RedisModuleString **err) {
28 REDISMODULE_NOT_USED(name);
29 REDISMODULE_NOT_USED(err);
30 *(int *)privdata = val;
31 return REDISMODULE_OK;
32}
33
34int get_bool_config(const char *name, void *privdata) {
35 REDISMODULE_NOT_USED(name);
36 return *(int *)privdata;
37}
38
39int RegisterModuleConfig(RedisModuleCtx *ctx) {
40 // Numeric parameters
41 RM_TRY(
42 RedisModule_RegisterBoolConfig(
43 ctx, "vset-force-single-threaded-execution", 0,
44 REDISMODULE_CONFIG_UNPREFIXED,
45 get_bool_config, set_bool_config, NULL,
46 (void *)&(VSGlobalConfig.forceSingleThreadExec)
47 )
48 )
49
50 return REDISMODULE_OK;
51}