Use disc_only_copies for oauth_token Mnesia table

This commit is contained in:
Evgeniy Khramtsov 2017-05-17 17:42:22 +03:00
parent 8f595b58a7
commit 1391d5a304
1 changed files with 13 additions and 2 deletions

View File

@ -29,17 +29,28 @@
-export([init/0, -export([init/0,
store/1, store/1,
lookup/1, lookup/1,
clean/1]). clean/1,
use_cache/0]).
-include("ejabberd_oauth.hrl"). -include("ejabberd_oauth.hrl").
init() -> init() ->
ejabberd_mnesia:create(?MODULE, oauth_token, ejabberd_mnesia:create(?MODULE, oauth_token,
[{disc_copies, [node()]}, [{disc_only_copies, [node()]},
{attributes, {attributes,
record_info(fields, oauth_token)}]), record_info(fields, oauth_token)}]),
ok. ok.
use_cache() ->
case mnesia:table_info(oauth_token, storage_type) of
disc_only_copies ->
ejabberd_config:get_option(
oauth_use_cache,
ejabberd_config:use_cache(global));
_ ->
false
end.
store(R) -> store(R) ->
mnesia:dirty_write(R). mnesia:dirty_write(R).