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 | |
parent | 9695231c327e052c5d5bc61197cc8222599fb91a (diff) | |
download | shard-f8702768d38381390bcdaf50ada28239aab87b56.tar.gz shard-f8702768d38381390bcdaf50ada28239aab87b56.zip |
Fix cleanups ?
Diffstat (limited to 'shard/lib')
-rw-r--r-- | shard/lib/app/blockstore.ex | 8 | ||||
-rw-r--r-- | shard/lib/manager.ex | 4 |
2 files changed, 5 insertions, 7 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} diff --git a/shard/lib/manager.ex b/shard/lib/manager.ex index 8cedce2..7aa3758 100644 --- a/shard/lib/manager.ex +++ b/shard/lib/manager.ex @@ -148,9 +148,7 @@ defmodule Shard.Manager do add_peer(ip, port, state) currtime = System.os_time :second :ets.insert(state.outbox, {peer_id, msg, currtime}) - outbox_cleanup = [{{:_, :_, :'$1'}, - [{:<, :'$1', currtime - 60}], - [:'$1']}] + outbox_cleanup = [ {{:_, :_, :'$1'}, [{:<, :'$1', currtime - 60}], [true]} ] :ets.select_delete(state.outbox, outbox_cleanup) _ -> Logger.info "Dropping message #{inspect msg} for peer #{inspect peer_id}: peer not in database" |