summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/shared/io')
-rw-r--r-- | src/shared/io/shr_database.erl | 40 | ||||
-rw-r--r-- | src/shared/io/shr_timed_cache.erl | 2 |
2 files changed, 31 insertions, 11 deletions
diff --git a/src/shared/io/shr_database.erl b/src/shared/io/shr_database.erl index bffcb9f..60327a5 100644 --- a/src/shared/io/shr_database.erl +++ b/src/shared/io/shr_database.erl @@ -10,8 +10,8 @@ -export ( [ - insert/4, - fetch/2, + insert/5, + fetch/3, commit/1 ] ). @@ -34,21 +34,41 @@ do_remote_operation (Op, Params) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec insert (atom(), any(), shr_db_user:permission(), any()) -> 'ok'. -insert (DB, ObjectID, Permission, Value) -> - {atomic, _} = do_remote_operation(insert, [DB, ObjectID, Permission, Value]), +-spec insert + ( + atom(), + any(), + shr_db_user:permission(), + shr_db_user:permission(), + any() + ) + -> 'ok'. +insert (DB, ObjectID, ReadPerm, WritePerm, Value) -> + {atomic, _} = + do_remote_operation(insert, [DB, ObjectID, ReadPerm, WritePerm, Value]), + io:format ( "~nshr_database:insert(~p) -> ok.~n", - [{DB, ObjectID, Permission, Value}] + [{DB, ObjectID, ReadPerm, WritePerm, Value}] ), ok. --spec fetch (atom(), any()) -> ({'ok', any()} | 'not_found'). -fetch (DB, ObjectID) -> - {atomic, Reply} = do_remote_operation(read, [DB, ObjectID]), - io:format("~nshr_database:fetch(~p) -> ~p.~n", [{DB, ObjectID}, Reply]), +-spec fetch + ( + atom(), + any(), + shr_db_user:user() + ) + -> ({'ok', any()} | 'not_found'). +fetch (DB, ObjectID, Cred) -> + {atomic, Reply} = do_remote_operation(read, [DB, ObjectID, Cred]), + io:format + ( + "~nshr_database:fetch(~p) -> ~p.~n", + [{DB, ObjectID, Cred}, Reply] + ), Reply. -spec commit (shr_db_query:type()) -> 'ok'. diff --git a/src/shared/io/shr_timed_cache.erl b/src/shared/io/shr_timed_cache.erl index b89de48..de3d094 100644 --- a/src/shared/io/shr_timed_cache.erl +++ b/src/shared/io/shr_timed_cache.erl @@ -38,7 +38,7 @@ -spec add_to_cache (atom(), any(), any()) -> any(). add_to_cache (DB, Owner, ObjectID) -> {ok, TimerPID} = gen_server:start(?MODULE, {DB, {Owner, ObjectID}}, []), - {ok, Data} = shr_database:fetch(DB, ObjectID), + {ok, Data} = shr_database:fetch(DB, ObjectID, Owner), ets:insert(DB, {{Owner, ObjectID}, TimerPID, Data}), Data. |