Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 16399 invoked from network); 28 May 2010 07:37:09 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 28 May 2010 07:37:09 -0000 Received: (qmail 60367 invoked by uid 500); 28 May 2010 07:37:09 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 60245 invoked by uid 500); 28 May 2010 07:37:07 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 60237 invoked by uid 99); 28 May 2010 07:37:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 May 2010 07:37:06 +0000 X-ASF-Spam-Status: No, hits=-0.8 required=10.0 tests=AWL,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.78.103.231] (HELO vorsha.objectstyle.org) (208.78.103.231) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 28 May 2010 07:37:01 +0000 Received: (qmail 18211 invoked from network); 28 May 2010 07:36:40 -0000 Received: from unknown (HELO ?IPv6:::1?) (127.0.0.1) by localhost with SMTP; 28 May 2010 07:36:40 -0000 Message-Id: From: Andrus Adamchik To: user@cayenne.apache.org In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: More on caching Date: Fri, 28 May 2010 10:36:38 +0300 References: <92583F17-2CBA-45B5-9C5A-5F4FE81F9255@objectstyle.org> X-Mailer: Apple Mail (2.936) Ah that's right. A local query cache is created that belongs to this context only. Not sure if we need to document it though. This is the internal details that are likely to change between releases. Andrus On May 28, 2010, at 10:17 AM, Gary Jarrel wrote: > On Fri, May 28, 2010 at 4:43 PM, Andrus Adamchik > wrote: >> > >>> it seems that domain.getQueryCache().size() is returning 1 >>> >>> assertEquals(1, ((DataContext) >>> getDataContext()).getParentDataDomain().getQueryCache().size()); >>> assertEquals(1, ((DataContext) >>> getDataContext()).getQueryCache().size()); >> >> I guess DataContext is assigned a different QueryCache instance >> somehow. >> >> Andrus >> >> > > I've just traced though the code and it seems that the queryCache > member in DataContext never gets set. Cayenne uses the DataDomain > query cache which is created on the first execution of my select > query. The second select query also uses this cache. The call in the > first assertEquals uses this cache is subsequently returns the correct > result. However in the second assertEquals statement the method on > line 226 of DataContext is executed. > > public QueryCache getQueryCache() { > if (queryCache == null) { > synchronized (this) { > if (queryCache == null) { > > DataDomain domain = getParentDataDomain(); > queryCache = > domain.getQueryCacheFactory().getQueryCache( > domain.getProperties()); > } > } > } > > return queryCache; > } > > At this point queryCache within the DataContext is still null so it > goes of and creates another one hence the cache is empty. > > This could however be the correct behavior if the DataDomain holds the > shared cache, while the data context holds the local cache, but if > this is the case perhaps it needs to be documented a bit better? > > Cheers, > > Gary >