Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

adds expire time as parameter to merge

  • Loading branch information...
commit b15fd58413f4f3a9aafb3b6dec7e07c2bbc9e7d5 1 parent ad14922
Alvaro Videla authored

Showing 2 changed files with 7 additions and 14 deletions. Show diff stats Hide diff stats

  1. +1 5 ebin/phpcask.app
  2. +6 9 src/phpcask.erl
6 ebin/phpcask.app
@@ -17,10 +17,6 @@
17 17 {env, [
18 18
19 19 %% Default folder to store bitcask files.
20   - {dirname, "./priv/data"},
21   -
22   - %% Expiration time in seconds for the session data.
23   - {expiry_secs, 900}
24   -
  20 + {dirname, "./priv/data"}
25 21 ]}
26 22 ]}.
15 src/phpcask.erl
@@ -7,7 +7,7 @@
7 7 -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
8 8 terminate/2, code_change/3]).
9 9
10   --export([get/1, put/2, delete/1, list_keys/0, merge/0]).
  10 +-export([get/1, put/2, delete/1, list_keys/0, merge/1]).
11 11
12 12 -define(DEFAULT_DIR, "./priv/data").
13 13 -define(EXPIRY_SECS, 900).
@@ -17,7 +17,7 @@ start() -> gen_server:start({local, ?MODULE}, ?MODULE, [], []).
17 17 start_link() -> gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
18 18 stop() -> gen_server:cast(?MODULE, stop).
19 19
20   --record(state, {ref, dirname, expiry_secs}).
  20 +-record(state, {ref, dirname}).
21 21
22 22 get(Key) -> gen_server:call(?MODULE, {get, Key}).
23 23
@@ -30,13 +30,13 @@ delete(Key) ->
30 30 list_keys() ->
31 31 gen_server:call(?MODULE, {list_keys}).
32 32
33   -merge() ->
34   - gen_server:call(?MODULE, {merge}).
  33 +merge(Expire) when is_integer(Expire) ->
  34 + gen_server:call(?MODULE, {merge, Expire}).
35 35
36 36 init([]) ->
37 37 Dirname = get_dirname(),
38 38 Bitcask = bitcask:open(Dirname, [read_write]),
39   - {ok, #state{ref=Bitcask, dirname=Dirname, expiry_secs=get_expiry_secs()}}.
  39 + {ok, #state{ref=Bitcask, dirname=Dirname}}.
40 40
41 41 handle_call({get, Key}, _From, #state{ref=Bitcask}=State) ->
42 42 Reply =
@@ -58,7 +58,7 @@ handle_call({list_keys}, _From, #state{ref=Bitcask}=State) ->
58 58 Reply = bitcask:list_keys(Bitcask),
59 59 {reply, Reply, State};
60 60
61   -handle_call({merge}, _From, #state{dirname=Dirname, expiry_secs=Expire}=State) ->
  61 +handle_call({merge, Expire}, _From, #state{dirname=Dirname}=State) ->
62 62 Options = [{expiry_secs, Expire}],
63 63 bitcask:merge(Dirname, Options),
64 64 {reply, ok, State}.
@@ -72,9 +72,6 @@ code_change(_OldVsn, State, _Extra) -> {ok, State}.
72 72
73 73 get_dirname() ->
74 74 get_opt(dirname, ?DEFAULT_DIR).
75   -
76   -get_expiry_secs() ->
77   - get_opt(expiry_secs, ?EXPIRY_SECS).
78 75
79 76 get_opt(Key, Default) ->
80 77 case application:get_env(bitcask, Key) of

0 comments on commit b15fd58

Please sign in to comment.
Something went wrong with that request. Please try again.