Protect against cache_hits on non-existant entries This can happen if we load a shard set from the cache and then eject the shards before processing the cache_hit '$gen_cast' message. Instead of trying to be fancy and reinserting the shards into the cache directly we just rely on the fact that they'll be reinserted normally on the next request.
Project: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/commit/91b9716f Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/tree/91b9716f Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/diff/91b9716f Branch: refs/heads/import Commit: 91b9716f2c52107664ad1f994d28a56b83a0192c Parents: bd4b897 Author: Paul J. Davis <paul.joseph.da...@gmail.com> Authored: Tue Dec 11 15:11:15 2012 -0600 Committer: Paul J. Davis <paul.joseph.da...@gmail.com> Committed: Tue Dec 11 15:13:20 2012 -0600 ---------------------------------------------------------------------- src/mem3_shards.erl | 10 ---------- 1 file changed, 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-mem3/blob/91b9716f/src/mem3_shards.erl ---------------------------------------------------------------------- diff --git a/src/mem3_shards.erl b/src/mem3_shards.erl index 3cf35cf..3f974f3 100644 --- a/src/mem3_shards.erl +++ b/src/mem3_shards.erl @@ -131,9 +131,6 @@ handle_call(_Call, _From, St) -> handle_cast({cache_hit, DbName}, St) -> cache_hit(DbName), {noreply, St}; -handle_cast({maybe_cache_hit, DbName}, St) -> - maybe_cache_hit(DbName), - {noreply, St}; handle_cast({cache_insert, DbName, Shards}, St) -> {noreply, cache_free(cache_insert(St, DbName, Shards))}; handle_cast({cache_remove, DbName}, St) -> @@ -297,13 +294,6 @@ cache_remove(#st{cur_size=Cur}=St, DbName) -> end. cache_hit(DbName) -> - [{DbName, ATime}] = ets:lookup(?DBS, DbName), - NewATime = now(), - true = ets:delete(?ATIMES, ATime), - true = ets:insert(?ATIMES, {NewATime, DbName}), - true = ets:insert(?DBS, {DbName, NewATime}). - -maybe_cache_hit(DbName) -> case ets:lookup(?DBS, DbName) of [{DbName, ATime}] -> NewATime = now(),