Re: More on caching

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri May 28 2010 - 07:36:38 UTC

  • Next message: MGargan..scholar.com: "Re: Blobs in the DataContext"

    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 <andru..bjectstyle.org
    > > 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
    >



    This archive was generated by hypermail 2.0.0 : Fri May 28 2010 - 07:37:11 UTC