forked from ErlyORM/boss_db
-
Notifications
You must be signed in to change notification settings - Fork 0
/
boss_db_cache.erl
26 lines (23 loc) · 885 Bytes
/
boss_db_cache.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
-module(boss_db_cache).
-export([handle_record_news/3, handle_collection_news/3]).
handle_record_news(_, _, {Prefix, Key}) ->
boss_cache:delete(Prefix, Key),
{ok, cancel_watch}.
handle_collection_news(deleted, _, {Prefix, Key}) ->
boss_cache:delete(Prefix, Key),
{ok, cancel_watch};
handle_collection_news(created, _, {Prefix, Key}) ->
boss_cache:delete(Prefix, Key),
{ok, cancel_watch};
handle_collection_news(updated, {_Record, Attr, _OldVal, _NewVal}, {Prefix, Key}) when Attr =:= element(5, Key) ->
boss_cache:delete(Prefix, Key),
{ok, cancel_watch};
handle_collection_news(updated, {_Record, Attr, _OldVal, _NewVal}, {Prefix, Key}) ->
Conditions = element(2, Key),
case proplists:lookup(Attr, Conditions) of
none ->
ok;
_ ->
boss_cache:delete(Prefix, Key),
{ok, cancel_watch}
end.