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/01 11:09:29 UTC

[4/8] ddoc-cache commit: updated refs/heads/windsor-merge to 64bab93

Define a macro for the LRU cache name


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/4b1c758b
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/tree/4b1c758b
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/diff/4b1c758b

Branch: refs/heads/windsor-merge
Commit: 4b1c758b58da9615eb10320add30a4628002b23f
Parents: 72f6af5
Author: Brian Mitchell <br...@cloudant.com>
Authored: Fri Oct 11 11:04:00 2013 -0400
Committer: Robert Newson <rn...@apache.org>
Committed: Tue Jul 29 11:50:47 2014 +0100

----------------------------------------------------------------------
 src/ddoc_cache_opener.erl | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-ddoc-cache/blob/4b1c758b/src/ddoc_cache_opener.erl
----------------------------------------------------------------------
diff --git a/src/ddoc_cache_opener.erl b/src/ddoc_cache_opener.erl
index e949f60..258b5fc 100644
--- a/src/ddoc_cache_opener.erl
+++ b/src/ddoc_cache_opener.erl
@@ -13,10 +13,8 @@
 -module(ddoc_cache_opener).
 -behaviour(gen_server).
 
-
 -include_lib("mem3/include/mem3.hrl").
 
-
 -export([
     start_link/0
 ]).
@@ -41,6 +39,7 @@
 ]).
 
 
+-define(CACHE, ddoc_cache_lru).
 -define(OPENING, ddoc_cache_opening).
 
 -type dbname() :: iodata().
@@ -120,9 +119,9 @@ handle_cast({do_evict, DbName}, St) ->
     handle_cast({do_evict, DbName, DDocIds}, St);
 
 handle_cast({do_evict, DbName, DDocIds}, St) ->
-    ets_lru:remove(ddoc_cache_lru, {DbName, validation_funs}),
+    ets_lru:remove(?CACHE, {DbName, validation_funs}),
     lists:foreach(fun(DDocId) ->
-        ets_lru:remove(ddoc_cache_lru, {DbName, DDocId})
+        ets_lru:remove(?CACHE, {DbName, DDocId})
     end, DDocIds),
     {noreply, St};
 
@@ -181,12 +180,12 @@ open_ddoc({DbName, validation_funs}=Key) ->
             Fun -> [Fun]
         end
     end, DDocs),
-    ok = ets_lru:insert(ddoc_cache_lru, {DbName, validation_funs}, Funs),
+    ok = ets_lru:insert(?CACHE, {DbName, validation_funs}, Funs),
     exit({open_ok, Key, {ok, Funs}});
 open_ddoc({DbName, DDocId}=Key) ->
     try fabric:open_doc(DbName, DDocId, [ejson_body]) of
         {ok, Doc} ->
-            ok = ets_lru:insert(ddoc_cache_lru, {DbName, DDocId}, Doc),
+            ok = ets_lru:insert(?CACHE, {DbName, DDocId}, Doc),
             exit({open_ok, Key, {ok, Doc}});
         Else ->
             exit({open_ok, Key, Else})