-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap_client.erl
46 lines (40 loc) · 931 Bytes
/
map_client.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
-module(map_client).
-export([get_value/2, set_value/3, get_size/1, get_keys/1, delete/2, exists/2]).
get_value(Server, Key) ->
Server ! {self(), {get, Key}},
receive
{Server, {ok, Value}} ->
Value;
{Server, error} ->
error
end.
set_value(Server, Key, Value) ->
Server ! {self(), {set, Key, Value}},
receive
{Server, {ok, Key, Value}} ->
ok
end.
get_size(Server) ->
Server ! {self(), {size}},
receive
{Server, {ok, Size}} ->
Size
end.
get_keys(Server) ->
Server ! {self(), {keys}},
receive
{Server, Keys} ->
Keys
end.
delete(Server, Key) ->
Server ! {self(), {delete, Key}},
receive
{Server, {ok, Key}} ->
ok
end.
exists(Server, Key) ->
Server ! {self(), {exists, Key}},
receive
{Server, Value} ->
Value
end.