cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Huss <johnth...@gmail.com>
Subject Re: fetching from cache without sql transaction
Date Tue, 17 Sep 2019 17:10:24 GMT
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 <abapseres@bapseres.fr> 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
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message