Re: caching query behavior changed?

From: Bryan Lewis (brya..aine.rr.com)
Date: Tue Aug 01 2006 - 15:55:38 EDT

  • Next message: Øyvind Harboe: "Is matchExp case insensitive or not?"

    Thanks, y'all. The cachePolicy works.

    P.S. The ability to define the query in the modeler was kinda cool, but
    I'm one of those old-fashioned programmers that likes to keep things in
    the code. Don't bother adding declarative invalidation policies for me. :-)

    Andrus Adamchik wrote:

    >
    > On Aug 1, 2006, at 2:52 PM, Bryan Lewis wrote:
    >
    >> I have some old code that I've been running for a long time. It
    >> creates
    >> a caching SelectQuery like this:
    >>
    >> SelectQuery query = new SelectQuery("MyEntityName");
    >> query.setCachePolicy(QueryMetadata.SHARED_CACHE);
    >> query.setName("MyQueryName");
    >> if (refreshing) {
    >> query.setRefreshingObjects(true);
    >> }
    >> else {
    >> query.setRefreshingObjects(false);
    >> }
    >> List objects = dataContext.performQuery(query);
    >
    >
    > The change in 1.2 was in better defining the distinction of "cache
    > policy" vs. "refreshingObjects" flag. The former defines whether the
    > query is run at all; the later - whether the individual objects
    > within the result are refreshed IF the query is run. The other way of
    > looking at it is "list caching vs. object caching".
    >
    > So to force a refetch you may do this:
    >
    > query.setName("MyQueryName");
    > if (refreshing) {
    > query.setCachePolicy(QueryMetadata.SHARED_CACHE_REFRESH);
    > }
    > else {
    > query.setCachePolicy(QueryMetadata.SHARED_CACHE);
    > }
    >
    > Andrus
    >
    > P.S. as an aside, I already have some code on the HEAD (Cayenne 3.0)
    > that support pluggable cache managers, so the query results can be
    > invalidated based on some declarative policy, instead of doing this
    > in the code.
    >



    This archive was generated by hypermail 2.0.0 : Tue Aug 01 2006 - 15:56:09 EDT