AW: clear caches

From: Peter Schröder (Peter.Schroede..reenet-ag.de)
Date: Thu Jan 04 2007 - 02:45:01 EST

  • Next message: Andrus Adamchik: "[ANN] Cayenne Becomes a Top Level Apache Project"

    thank you for the instant help.

    -----Ursprüngliche Nachricht-----
    Von: Andrus Adamchik [mailto:andru..bjectstyle.org]
    Gesendet: Mittwoch, 3. Januar 2007 18:36
    An: cayenne-use..ncubator.apache.org
    Betreff: Re: clear caches

    Actually running a SelectQuery would always result in fresh data,
    unless you explicitly set it to not refresh objects and/or use cached
    results.

    Where the caching can bite you is reading objects via relationships
    or via DataObjectUtils. These would use cache. See my comments below
    on how to ensure those are invalidated.

    > context.getEntityResolver().clearCache();

    This is not needed - it clears cached mapping metadata, not the objects.

    > context.getObjectStore().getDataRowCache().clear();

    Yep - this one will clear shared cache. In addition, if you want to
    refresh everything, you would also need to replace DataContext with a
    new instance. Finally there is DataContext.invalidateObjects() method
    that allows targeted invalidation of specific objects.

    Andrus

    On Jan 3, 2007, at 3:02 PM, Peter Schröder wrote:
    > hi and happy new year,
    >
    > i am looking for a method that tells cayenne to clear all cached
    > objects, so that i can be sure the context will read fresh data
    > from database next time a query is performed.
    >
    > i found these:
    >
    > context.getEntityResolver().clearCache();
    > context.getObjectStore().getDataRowCache().clear();
    >
    > kind regards,
    > peter
    >



    This archive was generated by hypermail 2.0.0 : Thu Jan 04 2007 - 02:45:45 EST