25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

Add clear_cache admin command

This commit is contained in:
Evgeniy Khramtsov 2017-04-22 11:33:39 +03:00
parent 44ae6bcc83
commit 18433e289f
2 changed files with 11 additions and 2 deletions

View File

@ -20,7 +20,7 @@
{deps, [{lager, ".*", {git, "https://github.com/basho/lager", {tag, "3.2.1"}}},
{p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.8"}}},
{cache_tab, ".*", {git, "https://github.com/processone/cache_tab", "8985b03"}},
{cache_tab, ".*", {git, "https://github.com/processone/cache_tab", "b0c787a"}},
{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.11"}}},
{stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.8"}}},
{fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.21"}}},

View File

@ -54,6 +54,7 @@
dump_to_textfile/1, dump_to_textfile/2,
mnesia_change_nodename/4,
restore/1, % Still used by some modules
clear_cache/0,
get_commands_spec/0
]).
%% gen_server callbacks
@ -360,7 +361,11 @@ get_commands_spec() ->
module = ?MODULE, function = install_fallback_mnesia,
args_desc = ["Full path to the fallback file"],
args_example = ["/var/lib/ejabberd/database.fallback"],
args = [{file, string}], result = {res, restuple}}
args = [{file, string}], result = {res, restuple}},
#ejabberd_commands{name = clear_cache, tags = [server],
desc = "Clear database cache on all nodes",
module = ?MODULE, function = clear_cache,
args = [], result = {res, rescode}}
].
@ -759,3 +764,7 @@ mnesia_change_nodename(FromString, ToString, Source, Target) ->
{[Other], Acc}
end,
mnesia:traverse_backup(Source, Target, Convert, switched).
clear_cache() ->
Nodes = ejabberd_cluster:get_nodes(),
lists:foreach(fun(T) -> ets_cache:clear(T, Nodes) end, ets_cache:all()).