Re: fetching from cache without sql transaction
John Huss <[email protected]>
| Newsgroups | gmane.comp.java.cayenne.user |
|---|---|
| Message-ID | <CAOUwSGvtGvgDs2-EW+UjiDme2eNTNijb6dqc6Q-w4ay6BvbhhQ@mail.gmail.com> |
LOCAL_CACHE will only return cached data for queries using the *same* objectContext, which is usually the same HTTP request). If you have different objectContexts (requests) then you have to use SHARED_CACHE instead. Then you have to figure out when to invalidate/expire the cached data. On Tue, Sep 17, 2019 at 2:29 AM abapseres <[email protected]> wrote: > Hello, > > I would to know if it's possible to fetch newObject directely from cache > with ObjectSelect. > > For now i don't manage to do this, for example when I make something like > that : > > > List<MyTable> list1 = ObjectSelect.query(MyTable.class) > > .cacheStrategy(QueryCacheStrategy.LOCAL_CACHE,"MyGroup") > > .select(getObjectContext()); > > > MyTable o1 = getObjectContext().newObject(MyTable.class); > > o1.setName("nouveau"); > > getObjectContext().commitChanges(); > > > > List<MyTable> list2 = ObjectSelect.query(MyTable.class) > > .cacheStrategy(QueryCacheStrategy.LOCAL_CACHE,"MyGroup") > > .select(getObjectContext()); > > > For result list1 and list2 have same size, i have to switch > QueryCacheStrategy to LOCAL_CACHE_REFRESH to get new row, but there is a > database transaction. > > > Thanks > > >