summaryrefslogtreecommitdiff
path: root/src/ddoc_cache/src/ddoc_cache_lru.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/ddoc_cache/src/ddoc_cache_lru.erl')
-rw-r--r--src/ddoc_cache/src/ddoc_cache_lru.erl28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/ddoc_cache/src/ddoc_cache_lru.erl b/src/ddoc_cache/src/ddoc_cache_lru.erl
index ec8f5caaa..d2b226710 100644
--- a/src/ddoc_cache/src/ddoc_cache_lru.erl
+++ b/src/ddoc_cache/src/ddoc_cache_lru.erl
@@ -296,16 +296,24 @@ remove_key(St, Key) ->
} = St,
DbName = ddoc_cache_entry:dbname(Key),
DDocId = ddoc_cache_entry:ddocid(Key),
- {value, DDocIds} = khash:lookup(Dbs, DbName),
- {value, Keys} = khash:lookup(DDocIds, DDocId),
- khash:del(Keys, Key),
- case khash:size(Keys) of
- 0 -> khash:del(DDocIds, DDocId);
- _ -> ok
- end,
- case khash:size(DDocIds) of
- 0 -> khash:del(Dbs, DbName);
- _ -> ok
+ case khash:lookup(Dbs, DbName) of
+ {value, DDocIds} ->
+ case khash:lookup(DDocIds, DDocId) of
+ {value, Keys} ->
+ ok = khash:del(Keys, Key),
+ case khash:size(Keys) of
+ 0 -> khash:del(DDocIds, DDocId);
+ _ -> ok
+ end,
+ case khash:size(DDocIds) of
+ 0 -> khash:del(Dbs, DbName);
+ _ -> ok
+ end;
+ not_found ->
+ ok
+ end;
+ not_found ->
+ ok
end.
unlink_and_flush(Pid) ->