cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <mkien...@gmail.com>
Subject Re: 3.0 -> 3.1: Committed changes not propagating to other contexts / invalidating objects not removing cached values
Date Mon, 04 Nov 2013 15:59:03 GMT
The full patch looks like it would need to be something like this:

--- framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java
   (revision 1524993)
+++ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java
   (working copy)
@@ -272,6 +272,9 @@
                 // not sending any events - peer contexts will not
get refreshed
                 if (domain.getSharedSnapshotCache() != null) {
                     domain.getSharedSnapshotCache().clear();
+                } else {
+                    // remove snapshots from local ObjectStore only
+                    context.getObjectStore().getDataRowCache().clear();
                 }
                 context.getQueryCache().clear();

@@ -298,8 +301,16 @@
                             Collections.EMPTY_LIST,
                             ids,
                             Collections.EMPTY_LIST);
+                } else {
+                    // remove snapshots from local ObjectStore only
+
context.getObjectStore().getDataRowCache().processSnapshotChanges(
+                            context.getObjectStore(),
+                            Collections.EMPTY_MAP,
+                            Collections.EMPTY_LIST,
+                            ids,
+                            Collections.EMPTY_LIST);
                 }

                 GenericResponse response = new GenericResponse();
                 response.addUpdateCount(1);
                 this.response = response;



On Mon, Nov 4, 2013 at 10:48 AM, Mike Kienenberger <mkienenb@gmail.com> wrote:
> I reran my tests, and, yes, the invalidateObjects is failing because I
> had sharedCacheEnabled set to false.  (I had set it in my java code
> rather than in the model, so it took me awhile to find it.)
>
>             dataDomain.setSharedCacheEnabled(false);
>
> Once I change that to true, invalidateObjects works again.
>
> The problem appears to be in DataDomainQueryAction.interceptRefreshQuery()
>
>                 if (domain.getSharedSnapshotCache() != null) {
>                     // send an event for removed snapshots
>                     domain.getSharedSnapshotCache().processSnapshotChanges(
>                             context.getObjectStore(),
>                             Collections.EMPTY_MAP,
>                             Collections.EMPTY_LIST,
>                             ids,
>                             Collections.EMPTY_LIST);
>                 }
>
> should have an else statement along these lines.
>
>                else {
>                      // remove snapshots from local ObjectStore only
>
> context.getObjectStore(),getDataRowCache().processSnapshotChanges(
>                             context.getObjectStore(),
>                             Collections.EMPTY_MAP,
>                             Collections.EMPTY_LIST,
>                             ids,
>                             Collections.EMPTY_LIST);
>               }
>
>
> On Mon, Nov 4, 2013 at 8:44 AM, Mike Kienenberger <mkienenb@gmail.com> wrote:
>> On Mon, Nov 4, 2013 at 8:36 AM, Andrus Adamchik <andrus@objectstyle.org> wrote:
>>> ObjectStores listen for each other’s events. See ObjectStore.setDataRowCache(..)
(BTW this is the code I want to simplify per 'Removing "use shared cache” option’ thread).
>>
>> I wonder if I had unchecked "use shared cache" when I was looking into
>> this problem.
>>
>> I haven't looked at this in a month, so I'll have to go review it
>> again.   I'll try to find some time to do that today.

Mime
View raw message