summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2018-12-15 21:48:06 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2018-12-15 21:48:06 +0100
commit71a4a4195292bef8f48e8a533f2d31bc4a53ac2e (patch)
treec1ca60280c192d95a978ea36d22fe68506abe75b /src/shared/io
parent69968df5ed21045e7a3679239705a397133db67b (diff)
Seems to be working again.
Diffstat (limited to 'src/shared/io')
-rw-r--r--src/shared/io/shr_timed_cache.erl23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/shared/io/shr_timed_cache.erl b/src/shared/io/shr_timed_cache.erl
index ff6e13d..45ddb1a 100644
--- a/src/shared/io/shr_timed_cache.erl
+++ b/src/shared/io/shr_timed_cache.erl
@@ -35,14 +35,27 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--spec add_to_cache (atom(), any(), any()) -> any().
+-spec add_to_cache
+ (
+ atom(),
+ ataxia_security:user(),
+ ataxia_id:type()
+ )
+ -> any().
add_to_cache (DB, Owner, ObjectID) ->
{ok, TimerPID} = gen_server:start(?MODULE, {DB, {Owner, ObjectID}}, []),
{ok, Data} = ataxia_client:fetch(DB, Owner, ObjectID),
ets:insert(DB, {{Owner, ObjectID}, TimerPID, Data}),
Data.
--spec add_update_to_cache (atom(), any(), any(), any()) -> 'ok'.
+-spec add_update_to_cache
+ (
+ atom(),
+ ataxia_security:user(),
+ ataxia_id:type(),
+ any()
+ )
+ -> 'ok'.
add_update_to_cache (DB, Owner, ObjectID, Data) ->
{ok, TimerPID} = gen_server:start(?MODULE, {DB, {Owner, ObjectID}}, []),
ets:insert(DB, {{Owner, ObjectID}, TimerPID, Data}),
@@ -86,7 +99,7 @@ handle_info(_, {DB, ObjectID}) ->
{noreply, {DB, ObjectID}, shr_timed_caches_manager:get_timeout()}.
%%%% Interface Functions
--spec fetch (atom(), any(), any()) -> any().
+-spec fetch (atom(), ataxia_security:user(), ataxia_id:type()) -> any().
fetch (DB, Owner, ObjectID) ->
io:format("~nfetch from cache: ~p.~n", [{DB, {Owner, ObjectID}}]),
case ets:lookup(DB, {Owner, ObjectID}) of
@@ -97,7 +110,7 @@ fetch (DB, Owner, ObjectID) ->
Data
end.
--spec update (atom(), any(), any(), any()) -> 'ok'.
+-spec update (atom(), ataxia_security:user(), ataxia_id:type(), any()) -> 'ok'.
update (DB, Owner, ObjectID, Data) ->
io:format("~nUpdating cache: ~p.~n", [{DB, {Owner, ObjectID}}]),
case ets:lookup(DB, {Owner, ObjectID}) of
@@ -108,7 +121,7 @@ update (DB, Owner, ObjectID, Data) ->
end,
add_update_to_cache(DB, Owner, ObjectID, Data).
--spec invalidate (atom(), any(), any()) -> 'ok'.
+-spec invalidate (atom(), ataxia_security:user(), ataxia_id:type()) -> 'ok'.
invalidate (DB, Owner, ObjectID) ->
case ets:lookup(DB, {Owner, ObjectID}) of
[] ->