1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-06 03:50:15 +02:00

Use cache in front of Redis/SQL RAM backends

This commit is contained in:
Evgeniy Khramtsov 2017-04-14 13:57:52 +03:00
parent aa7d5df6a0
commit e40baf0bda
26 changed files with 1155 additions and 384 deletions

View file

@ -44,13 +44,18 @@ open_session(SID, Pid) ->
ok;
Err ->
?ERROR_MSG("failed to update 'bosh' table: ~p", [Err]),
{error, Err}
{error, db_failure}
end.
close_session(SID) ->
%% TODO: report errors
ejabberd_sql:sql_query(
?MYNAME, ?SQL("delete from bosh where sid=%(SID)s")).
case ejabberd_sql:sql_query(
?MYNAME, ?SQL("delete from bosh where sid=%(SID)s")) of
{updated, _} ->
ok;
Err ->
?ERROR_MSG("failed to delete from 'bosh' table: ~p", [Err]),
{error, db_failure}
end.
find_session(SID) ->
case ejabberd_sql:sql_query(
@ -58,13 +63,13 @@ find_session(SID) ->
?SQL("select @(pid)s, @(node)s from bosh where sid=%(SID)s")) of
{selected, [{Pid, Node}]} ->
try {ok, misc:decode_pid(Pid, Node)}
catch _:{bad_node, _} -> error
catch _:{bad_node, _} -> {error, notfound}
end;
{selected, []} ->
error;
{error, notfound};
Err ->
?ERROR_MSG("failed to select 'bosh' table: ~p", [Err]),
error
{error, db_failure}
end.
%%%===================================================================