From f8702768d38381390bcdaf50ada28239aab87b56 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 11 Sep 2018 17:48:48 +0200 Subject: Fix cleanups ? --- shard/lib/app/blockstore.ex | 8 ++++---- shard/lib/manager.ex | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'shard') 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" -- cgit v1.2.3