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 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'shard/lib/app') 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} -- cgit v1.2.3