Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7AF80112A5 for ; Fri, 1 Aug 2014 09:09:27 +0000 (UTC) Received: (qmail 9771 invoked by uid 500); 1 Aug 2014 09:09:27 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 9610 invoked by uid 500); 1 Aug 2014 09:09:27 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 9387 invoked by uid 99); 1 Aug 2014 09:09:27 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Aug 2014 09:09:27 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 0008F9BCB2D; Fri, 1 Aug 2014 09:09:26 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rnewson@apache.org To: commits@couchdb.apache.org Date: Fri, 01 Aug 2014 09:09:29 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [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 Authored: Fri Oct 11 11:04:00 2013 -0400 Committer: Robert Newson 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})