diff options
author | Alex Auvolat <alex@adnab.me> | 2018-09-11 17:48:48 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2018-09-11 17:48:48 +0200 |
commit | f8702768d38381390bcdaf50ada28239aab87b56 (patch) | |
tree | 4ac19ffadddd726090b80c5df3f1ae79ecce5e85 /shard/lib/app | |
parent | 9695231c327e052c5d5bc61197cc8222599fb91a (diff) | |
download | shard-f8702768d38381390bcdaf50ada28239aab87b56.tar.gz shard-f8702768d38381390bcdaf50ada28239aab87b56.zip |
Fix cleanups ?
Diffstat (limited to 'shard/lib/app')
-rw-r--r-- | shard/lib/app/blockstore.ex | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/shard/lib/app/blockstore.ex b/shard/lib/app/blockstore.ex index f1140b2..077235a 100644 --- a/shard/lib/app/blockstore.ex +++ b/shard/lib/app/blockstore.ex @@ -43,6 +43,7 @@ defmodule SApp.BlockStore do {:ok, %State{shard_id: shard_id, path: path, store: store, reqs: %{}, retries: %{}}} end + def handle_call({:get, key, prefer_ask}, from, state) do case :ets.lookup state.store, key do [{_, _, v}] -> @@ -215,10 +216,9 @@ defmodule SApp.BlockStore do def handle_info(:clean_cache, state) do currtime = System.os_time :seconds - cache_cleanup_1 = [ {{:_, {:cached, :'$1'}, :_}, [{:<, :'$1', currtime}], [:'$1']} ] - cache_cleanup_2 = [ {{:_, {:cached, :'$1'}}, [{:<, :'$1', currtime}], [:'$1']} ] - :ets.select_delete(state.store, cache_cleanup_1) - :ets.select_delete(state.store, cache_cleanup_2) + cache_cleanup = [ {{:_, {:cached, :'$1'}, :_}, [{:<, :'$1', currtime}], [true]}, + {{:_, {:cached, :'$1'}}, [{:<, :'$1', currtime}], [true]} ] + :ets.select_delete(state.store, cache_cleanup) Process.send_after(self(), :clean_cache, @clean_cache_every * 1000) {:noreply, state} |