Current section
2 Versions
Jump to
Current section
2 Versions
Compare versions
4
files changed
+24
additions
-4
deletions
| @@ -1,2 +1,24 @@ | |
| 1 1 | # ELRU |
| 2 2 | Implementation of LRU cache in Erlang OTP application |
| 3 | + This application store results of functions in ets based database. It calculate hash of ```[ModuleName, FunctionName, ListOfArgs]``` and store it in database. |
| 4 | + |
| 5 | + # Usage |
| 6 | + |
| 7 | + Add in rebar.config file : |
| 8 | + ```erlang |
| 9 | + {elru, "1.0.0"} |
| 10 | + ``` |
| 11 | + Then create new LRU cache : |
| 12 | + ```erlang |
| 13 | + Size = 12. |
| 14 | + elru:new(Size). |
| 15 | + ``` |
| 16 | + To add new element (execute function) or get value (if this function have been executed) type : |
| 17 | + ```erlang |
| 18 | + elru:add(ModuleName, FunctionName, [Arg1, Arg2, .., ArgN]). |
| 19 | + ``` |
| 20 | + # Examle |
| 21 | + ```erlang |
| 22 | + elru:new(12). |
| 23 | + elru:add(test, add, [1,2]). |
| 24 | + ``` |
| @@ -1,5 +1,5 @@ | |
| 1 1 | {<<"name">>,<<"elru">>}. |
| 2 | - {<<"version">>,<<"1.0.0">>}. |
| 2 | + {<<"version">>,<<"1.1.0">>}. |
| 3 3 | {<<"requirements">>,#{}}. |
| 4 4 | {<<"app">>,<<"elru">>}. |
| 5 5 | {<<"maintainers">>,[<<"Dylgyrzhapov Buin">>]}. |
| @@ -1,6 +1,6 @@ | |
| 1 1 | {application,elru, |
| 2 2 | [{description,"Implements LRU cache in Erlang OTP application"}, |
| 3 | - {vsn,"1.0.0"}, |
| 3 | + {vsn,"1.1.0"}, |
| 4 4 | {registered,[]}, |
| 5 5 | {mod,{elru_app,[]}}, |
| 6 6 | {applications,[kernel,stdlib]}, |
| @@ -39,9 +39,7 @@ handle_cast({check_size}, {Id, Count, MaxSize}) -> | |
| 39 39 | Size > MaxSize -> |
| 40 40 | List = ets:tab2list(Id), |
| 41 41 | Key = minimum(List), |
| 42 | - Val = ets:lookup(Id, Key), |
| 43 42 | ets:delete(Id, Key), |
| 44 | - ?LOG("Delete ~p",[Val]), |
| 45 43 | {noreply, {Id, Count, MaxSize}}; |
| 46 44 | true -> |
| 47 45 | {noreply, {Id, Count, MaxSize}} |