You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/08/28 14:17:47 UTC

[05/10] ddoc-cache commit: updated refs/heads/master to 4ffc6b0

Simplify pulling out all design document ids from the cache

This allows the code to avoid copying the entire ets entries into
code from a separate module for both efficiency and modularity
purposes. This requires the new ets_lru match code to function.

It currently uses match which is dispatched to the gen_server.
It might be wise to make it direct since the match code does not
update access times (or if it did, we could make that a cast).


Project: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/commit/8ab96835
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/tree/8ab96835
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/diff/8ab96835

Branch: refs/heads/master
Commit: 8ab968359919a42279603a52ea98a061d4037079
Parents: 4b1c758
Author: Brian Mitchell <br...@cloudant.com>
Authored: Fri Oct 11 12:25:34 2013 -0400
Committer: Robert Newson <rn...@apache.org>
Committed: Tue Jul 29 11:50:55 2014 +0100

----------------------------------------------------------------------
 src/ddoc_cache_opener.erl | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/blob/8ab96835/src/ddoc_cache_opener.erl
----------------------------------------------------------------------
diff --git a/src/ddoc_cache_opener.erl b/src/ddoc_cache_opener.erl
index 258b5fc..b34359f 100644
--- a/src/ddoc_cache_opener.erl
+++ b/src/ddoc_cache_opener.erl
@@ -105,17 +105,7 @@ handle_cast({evict, DbName, DDocIds}, St) ->
     {noreply, St};
 
 handle_cast({do_evict, DbName}, St) ->
-    % Bit of hack to introspect the ets_lru ETS tables directly
-    % but I think this is better than having to manage our own
-    % DbName -> DDocIdList table
-    DDocIds = ets:foldl(fun(Obj, Acc) ->
-        entry = element(1, Obj), % assert this is an entry record
-        {EntryDbName, EntryDDocId} = element(2, Obj),
-        case EntryDbName == DbName of
-            true -> [EntryDDocId | Acc];
-            false -> Acc
-        end
-    end, [], ddoc_cache_lru_objects),
+    DDocIds = ets_lru:match(?CACHE, {DbName, '$1'}, '_'),
     handle_cast({do_evict, DbName, DDocIds}, St);
 
 handle_cast({do_evict, DbName, DDocIds}, St) ->