Re: Object Caching

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Nov 11 2009 - 08:53:27 EST

  • Next message: Andrey Razumovsky: "Re: complex query vs performIteratedQuery vs Prefetching"

    As mentioned in the docs, individual objects and query lists are
    cached independently. Of course query lists contain a subset of cached
    object store objects inside the lists. An object won't get gc'd if it
    is also stored in the query list.

    Now list cache expiration is controlled via query cache factory. By
    default this is an LRU map, so as long as the map has enough space to
    hold lists (its capacity == # of lists, not # of objects), the objects
    won't get gc'd.

    You can explicitly remove entries from the cache via QueryCache remove
    and removeGroup methods. Or you can use a different QueryCacheFactory
    that implements some custom expiration/cleanup mechanism.

    Andrus

    On Nov 11, 2009, at 3:43 PM, Hans Pikkemaat wrote:

    > Hi,
    >
    > I use the latest version of cayenne, 3.0b and am experimenting with
    > the object caching features.
    >
    > The documentation states that committed objects are purged from the
    > cache because it uses weak references.
    > (http://cayenne.apache.org/doc/individual-object-caching.html)
    >
    > If I however run a query using SQLTemplate which caches the objects
    > into the dataContext local cache (objectstore),
    > the objects don't seem to be purged at all. If I simply run the
    > query dump the contents using an iterator on the resulting
    > List then the nr of registered objects in the objectstore stays the
    > same (dataContext.getObjectStore().registeredObjectsCount()).
    > Even if I manually run System.gc() I don't see any changes (I know
    > this can be normal as gc() doesn't guarantee anything)
    >
    > What am I doing wrong? Under which circumstances will cayenne purge
    > the cache?
    >
    > tx
    >
    > Hans
    >



    This archive was generated by hypermail 2.0.0 : Wed Nov 11 2009 - 08:54:17 EST