Skip to content

Commit

Permalink
Change cache ets table from set to bag
Browse files Browse the repository at this point in the history
As the tables are created per-host-type, a table can have more than one
domain within, and so there's no unique key properly defined,
considering that the same namepart can be used in two different domains,
and the same domain contains many nameparts.

Restore it as a set, and actually fix the key inserted
  • Loading branch information
NelsonVides committed Jun 23, 2021
1 parent 78880e6 commit 23029ad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mongoose_users.erl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ remove_user(Acc, LUser, LServer) ->
mongoose_hooks:simple_acc().
remove_domain(Acc, HostType, Domain) ->
Tab = tbl_name(HostType),
ets:match_delete(Tab, {Domain, '_'}),
ets:match_delete(Tab, {{Domain, '_'}}),
Acc.

%%====================================================================
Expand All @@ -107,7 +107,7 @@ does_cached_user_exist(HostType, LServer, LUser) ->
put_user_into_cache(HostType, LServer, LUser) ->
Key = key(LUser, LServer),
Tab = tbl_name(HostType),
ets:insert(Tab, Key),
ets:insert(Tab, {Key}),
ok.

-spec delete_user(mongooseim:host_type(), jid:lserver(), jid:luser()) -> ok.
Expand Down

0 comments on commit 23029ad

Please sign in to comment.