1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-03 17:59:31 +02:00

Implement cache for mod_last

This commit is contained in:
Evgeniy Khramtsov 2017-05-18 13:21:17 +03:00
parent 736a182544
commit bcb44ccb6f
4 changed files with 126 additions and 34 deletions

View file

@ -45,17 +45,24 @@ init(_Host, _Opts) ->
get_last(LUser, LServer) ->
case catch sql_queries:get_last(LServer, LUser) of
{selected, []} ->
not_found;
error;
{selected, [{TimeStamp, Status}]} ->
{ok, TimeStamp, Status};
{ok, {TimeStamp, Status}};
Reason ->
?ERROR_MSG("failed to get last for user ~s@~s: ~p",
[LUser, LServer, Reason]),
{error, {invalid_result, Reason}}
{error, db_failure}
end.
store_last_info(LUser, LServer, TimeStamp, Status) ->
sql_queries:set_last_t(LServer, LUser, TimeStamp, Status).
case sql_queries:set_last_t(LServer, LUser, TimeStamp, Status) of
ok ->
ok;
Err ->
?ERROR_MSG("failed to store last activity for ~s@~s: ~p",
[LUser, LServer, Err]),
{error, db_failure}
end.
remove_user(LUser, LServer) ->
sql_queries:del_last(LServer, LUser).