mirror of https://mirror.osredm.com/root/redis.git
* only use new api if override-default was provided as an argument
This commit is contained in:
parent
83c0348553
commit
b9361ad5fe
|
@ -252,10 +252,11 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
|||
size_t len;
|
||||
if (argc && !strcasecmp(RedisModule_StringPtrLen(argv[0], &len), "noload")) {
|
||||
return REDISMODULE_OK;
|
||||
} else if (RedisModule_LoadDefaultConfigs(ctx) == REDISMODULE_ERR) {
|
||||
RedisModule_Log(ctx, "warning", "Failed to load default configuration");
|
||||
goto err;
|
||||
} else if (argc && !strcasecmp(RedisModule_StringPtrLen(argv[0], &len), "override")) {
|
||||
} if (argc && !strcasecmp(RedisModule_StringPtrLen(argv[0], &len), "override-default")) {
|
||||
if (RedisModule_LoadDefaultConfigs(ctx) == REDISMODULE_ERR) {
|
||||
RedisModule_Log(ctx, "warning", "Failed to load default configuration");
|
||||
goto err;
|
||||
}
|
||||
// simulate configuration values being overwritten by the command line
|
||||
RedisModule_Log(ctx, "debug", "Overriding configuration values");
|
||||
if (strval) RedisModule_FreeString(ctx, strval);
|
||||
|
|
|
@ -348,7 +348,7 @@ start_server {tags {"modules"}} {
|
|||
r module loadex $testmodule \
|
||||
CONFIG moduleconfigs.string goo \
|
||||
CONFIG moduleconfigs.memory_numeric 2mb \
|
||||
ARGS override
|
||||
ARGS override-default
|
||||
|
||||
# Verify CONFIG values took precedence over the pseudo values that
|
||||
assert_equal [r config get moduleconfigs.string] "moduleconfigs.string goo"
|
||||
|
@ -360,7 +360,7 @@ start_server {tags {"modules"}} {
|
|||
# Test: Ensure that modified configuration values from ARGS are correctly written to the config file
|
||||
test {Modified ARGS values are persisted after config rewrite when set through CONFIG commands} {
|
||||
# Load module with non-default ARGS values
|
||||
r module loadex $testmodule ARGS override
|
||||
r module loadex $testmodule ARGS override-default
|
||||
|
||||
# Verify the initial values were overwritten
|
||||
assert_equal [r config get moduleconfigs.memory_numeric] "moduleconfigs.memory_numeric 123"
|
||||
|
|
Loading…
Reference in New Issue