Re: Invalidate lookup tables cache?

From: Mike Kienenberger (mkienen..laska.net)
Date: Wed Jul 21 2004 - 10:08:28 EDT

  • Next message: Mike Kienenberger: "Re: cayenne and eclipse pde"

    Twan Kogels <twa..wansoft.com> wrote:
    > The last 2 days i've been busy to get better performance for my
    > webapplication. I did the thing with prefetching relationships, that
    worked
    > very nice. I'm now using the method described on:
    > <http://www.objectstyle.org/cayenne/userguide/perform/caching-lookup.html>
    > to optimize my lookup tables.
    >
    > The records in the lookup table are mostly readonly. But sometimes (once a

    > month or once in two months) someone decides that a value in a lookup
    table
    > should be changed or added.
    >
    > So i checked the "Refresh objects" checkbox in the Modeler. I thought this

    > one means "invalidate cache when insert/update/delete occurs".
    >
    > But when i do a update/insert/delete in the lookup table the cache doesn't

    > get refreshed.
    >
    > I use the following code to get objects from the lookup table:
    > ==================
    > return ctxt.performQuery("AlleSectoren", false);
    > ==================
    > "AlleSectoren" is a selectquery with properties as stated on:
    > <http://www.objectstyle.org/cayenne/userguide/perform/caching-lookup.html>
    > but with "Refresh objects" checkbox on.
    >
    > I add a object to the lookup table with the following code:
    > ==================
    > Object o = ctxt.createAndRegisterNewObject(tabel);
    > ( (Sector) o).setNaam(naam);
    > ==================
    >
    > The added object is added to the lookup table. But when executing another:
    > ==================
    > return ctxt.performQuery("AlleSectoren", false);
    > ==================
    > the added/new object doesn't show up. I see in my log that cayenne doesn't

    > execute a query to my database so i guess cayenne takes the objects from
    > the cache.
    >
    > Should i maybe manually invalidate the cache?
    >
    > I'm currently using cayenne-1.1M7_1 and a mysql 4.x database.

    I haven't used this feature yet myself, but I'd guess that you could either
    call the following method explicitly after an update (which seems like a
    sure thing),

        return ctxt.performQuery("AlleSectoren", true);

    or you could try doing this for an object you just want to update.

            ctxt.invalidateObjects(Collections.singletonList(o));

    If you're adding or deleting, you're probably going to want to stick with
    the first one.



    This archive was generated by hypermail 2.0.0 : Wed Jul 21 2004 - 10:08:16 EDT