Re: Best way to inform (and handle cached object refreshing) of externally-updated database records?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Nov 22 2004 - 13:27:54 EST

  • Next message: Mike Kienenberger: "Re: Best way to inform (and handle cached object refreshing) of externally-updated database records?"

    Then how about turning off shared cache all together ("Use Shared Cache"
    checkbox for DataDomain). This will put Cayenne in a "1.0 mode" with each
    DataContext having its own cache. This way new DataContexts will start
    empty, and will be filled with fresh data as you run queries or resolve
    relationships.

    [Also if you go with this option, I suggest reducing "max number of
    objects" for the DataDomain cache from 10000 to something smaller, as this
    will now be multiplied by the number of DataContexts].

    Andrus

    > Andrus Adamchik <andru..bjectstyle.org> wrote:
    >> 1. Use Cayenne built-in remote notifications.
    >> Good thing about snapshot
    >> events is that you can tell the listener exactly which objects were
    >> modified.
    >
    > Thanks. The batch job updates hundreds of thousands of account objects,
    > most of which aren't used by my web application, so providing a list of
    > which objects were modified is probably not a good strategy in this
    > case.
    >
    >
    >> 2. Continue using LAST_EXTERNAL_UPDATE and manually invalidate cache.
    >>
    >> Here is one (but not the only) way to do that for just the shared
    >> entities. For each "shared" entity create a named query in the Modeler
    >> with Result Caching policy of "Shared Cache". Whenever you detect
    >> from LAST_EXTERNAL_UPDATE that refresh is needed, you can do a
    >> refresh like that:
    >>
    >> 2a. Call "DateRowStore.cacheSnapshots("query_name", null) for each
    >> "shared" query. This assumes that all your DataContexts access shared
    >> object via such queries, and in no other way, and also that you don't
    >> mind stale data in existing DataContexts.
    >>
    >> or
    >>
    >> 2b. Call DataContext.performQuery("query_name", true) for each shared
    >> query. This will give you fresh objects immediately and as a side
    >> effect refresh shared cache.
    >
    > The problem is that my account objects are loaded indirectly. I don't
    > pull them in as a result of an explicit query, but only as the result
    > of referencing a relationship getter method on other objects.
    >
    > Is there a way to handle this without using a shared cache?
    >
    > What about using
    >
    > getDataContext().getObjectStore().getObjects()
    >
    > to iterate through all objects (does the above get all objects or only
    > objects registered to a particular DataContext?), and then invalidating
    > all objects of a specific (in this case "account") class?
    >
    > I don't mind having stale data in existing datacontexts, so long as when
    > new contexts are created via
    > BasicServletConfiguration.getDefaultContext(), they have current data.
    >
    > -Mike



    This archive was generated by hypermail 2.0.0 : Mon Nov 22 2004 - 13:27:56 EST