diff options
author | Oran Agra <oran@redislabs.com> | 2021-02-01 20:11:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-01 20:11:42 +0200 |
commit | 2dba1e391d3772a8da182d95bde050ffa9d01e4d (patch) | |
tree | 3664bcd3ede605643a18668624f41c846b5e43ab /src/scripting.c | |
parent | ec2d180739aa3877a45ec54438c68a7659be5159 (diff) | |
parent | 95338f9cc41fdfd050f122789187db75fda1fe3c (diff) | |
download | redis-2dba1e391d3772a8da182d95bde050ffa9d01e4d.tar.gz |
Merge 6.2 RC36.2-rc3
Diffstat (limited to 'src/scripting.c')
-rw-r--r-- | src/scripting.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/scripting.c b/src/scripting.c index 75604e4d8..41469ee2e 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -1282,14 +1282,17 @@ void scriptingInit(int setup) { /* Release resources related to Lua scripting. * This function is used in order to reset the scripting environment. */ -void scriptingRelease(void) { - dictRelease(server.lua_scripts); +void scriptingRelease(int async) { + if (async) + freeLuaScriptsAsync(server.lua_scripts); + else + dictRelease(server.lua_scripts); server.lua_scripts_mem = 0; lua_close(server.lua); } -void scriptingReset(void) { - scriptingRelease(); +void scriptingReset(int async) { + scriptingRelease(async); scriptingInit(0); } @@ -1711,8 +1714,12 @@ void scriptCommand(client *c) { " Set the debug mode for subsequent scripts executed.", "EXISTS <sha1> [<sha1> ...]", " Return information about the existence of the scripts in the script cache.", -"FLUSH", +"FLUSH [ASYNC|SYNC]", " Flush the Lua scripts cache. Very dangerous on replicas.", +" When called without the optional mode argument, the behavior is determined by the", +" lazyfree-lazy-user-flush configuration directive. Valid modes are:", +" * ASYNC: Asynchronously flush the scripts cache.", +" * SYNC: Synchronously flush the scripts cache.", "KILL", " Kill the currently executing Lua script.", "LOAD <script>", @@ -1720,8 +1727,19 @@ void scriptCommand(client *c) { NULL }; addReplyHelp(c, help); - } else if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"flush")) { - scriptingReset(); + } else if (c->argc >= 2 && !strcasecmp(c->argv[1]->ptr,"flush")) { + int async = 0; + if (c->argc == 3 && !strcasecmp(c->argv[2]->ptr,"sync")) { + async = 0; + } else if (c->argc == 3 && !strcasecmp(c->argv[2]->ptr,"async")) { + async = 1; + } else if (c->argc == 2) { + async = server.lazyfree_lazy_user_flush ? 1 : 0; + } else { + addReplyError(c,"SCRIPT FLUSH only support SYNC|ASYNC option"); + return; + } + scriptingReset(async); addReply(c,shared.ok); replicationScriptCacheFlush(); server.dirty++; /* Propagating this command is a good idea. */ |