cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: SnapshotVersion
Date Thu, 09 Mar 2017 06:20:15 GMT
You can store those values in each DataObject instance variables and map a PostLoad callback
on the entity (Modeler > Select ObjEntity in question > Select "Callbacks" tab). In
the callback method you can reset the values. More info on callbacks:

http://cayenne.apache.org/docs/4.0/cayenne-guide/lifecycle-events.html

Andrus


> On Mar 8, 2017, at 10:31 PM, Markus Reich <markus.reich@markusreich.at> wrote:
> 
> Hi Andrus,
> 
> I have some getters in DataObjects that use some DB properties for
> calculation, e.g. I read other data from DB and to kind of lookups, so I
> got a much better performance when I introtuced a caching of this
> calculated values. I just use a concurrent hash map to realize the caching.
> Now I need a trigger for invalidation of the cached values, when the
> DataObject itself get's invalidated?
> 
> regards
> Meex
> 
> Andrus Adamchik <andrus@objectstyle.org> schrieb am Mi., 8. März 2017 um
> 20:24 Uhr:
> 
>> Hi Markus,
>> 
>> Snapshot version reflects the version of a cached snapshot that was used
>> to sync the current state of the object (this is probably obvious). The
>> behavior observed by you may actually be a bug (and we may need to
>> investigate it).
>> 
>> Generally I would recommend against relying too much on snapshot version
>> API. I always considered it an implementation detail (though of course it
>> is publicly accessible... oh well) that may easily fall victim of a future
>> DataObject redesign (e.g. see the parallel 'Fetching lots of objects'
>> thread).
>> 
>> Can you explain how your cache is intended to work? Perhaps there is a
>> callback/listener solution to it?
>> 
>> Andrus
>> 
>>> On Mar 6, 2017, at 5:04 PM, Markus Reich <markus.reich@markusreich.at>
>> wrote:
>>> 
>>> Hi,
>>> 
>>> I always thought that when the content of an object changes (by commit)
>> the
>>> version gets incremented. I analyzed this a bit further and found sthg.
>>> which is very clear for me :-/
>>> 
>>> When I have two DataObjects with the same key/id and I change a value in
>>> one Object, I got a higher version after committing the changes. The
>> other
>>> DataObjects also "gets" the new value, but the snapshot version stays the
>>> same?
>>> 
>>> The background is that I try to build a cache on computed values of
>>> DataObjects, so I need an indicator for invalidating my cache, I thought
>>> snapshot version would be perfect :-) but so it seems that this won't
>> work
>>> for my idea :-/
>>> 
>>> best regards
>>> Meex
>> 
>> 


Mime
View raw message