]> granicus.if.org Git - ejabberd/commitdiff
Add clear_cache admin command
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Sat, 22 Apr 2017 08:33:39 +0000 (11:33 +0300)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Sat, 22 Apr 2017 08:33:39 +0000 (11:33 +0300)
rebar.config
src/ejabberd_admin.erl

index 353bd2e77383f408175c23825f0e04b1dd5a96c9..71eebf6a97612abc8af17b3557c79e49f81f0f48 100644 (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"}}},
index 39262f0e49dc42dc3eff0c2dabc6a3bc130c20ca..15cd78c0289e49af4c5d3d69e5a10537969119fb 100644 (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()).