aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-04-22 11:33:39 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-04-22 11:33:39 +0300
commit18433e289ff0f208a9eb7bf0746c11033440469a (patch)
tree7fb9ea009e7dec8291bcbfd9650d406ee7f59750
parentFix elixir tests (diff)
Add clear_cache admin command
-rw-r--r--rebar.config2
-rw-r--r--src/ejabberd_admin.erl11
2 files changed, 11 insertions, 2 deletions
diff --git a/rebar.config b/rebar.config
index 353bd2e77..71eebf6a9 100644
--- a/rebar.config
+++ b/rebar.config
@@ -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"}}},
diff --git a/src/ejabberd_admin.erl b/src/ejabberd_admin.erl
index 39262f0e4..15cd78c02 100644
--- a/src/ejabberd_admin.erl
+++ b/src/ejabberd_admin.erl
@@ -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()).