Hi Gordon,

It looks like you turn off CacheConfguration.copyOnRead that is true by
default [1].
In this case you update cached value directly bypassing Ignite.

[1]
http://apacheignite.gridgain.org/docs/performance-tips#do-not-copy-value-on-read


On Mon, Feb 13, 2017 at 2:04 AM, gordon.reid@ninemilefinancial <
[email protected]> wrote:

> When updating entities in my cache, the oldValue=newValue in the event,
> unless I do a put with the original object instance. This is of course not
> always possible.
>
> Here is a simplified example.
>
> IgnitePredicate<CacheEvent> locLsnr = evt -> {
>     // do something
> };
> ignite.events().localListen(locLsnr,EventType.EVT_CACHE_OBJECT_PUT);
> IgniteCache<TradeKey, Trade> cache = ignite.getOrCreateCache("MyCache");
>
> Trade trade1 = new Trade();
> trade1.setId(1);
> trade1.setSize(10);
> cache.put(new TradeKey(trade.getId()), trade1);
> // event is generated
> //evt.oldValue is null, no problem
> trade1.setSize(20);
> cache.put(new TradeKey(trade.getId()), trade1);
> // event is generated
> // evt.oldValue().getSize() is 10, evt.newValue().getSize() is 20, this is
> GOOD
>
> But, if I retrieve the trade from the cache again before updating (from
> another part of the application for example), I am not able to see what the
> old value was in the event. Old value will just show the new value.
>
> IgnitePredicate<CacheEvent> locLsnr = evt -> {
>     // do something
> };
> ignite.events().localListen(locLsnr,EventType.EVT_CACHE_OBJECT_PUT);
> IgniteCache<TradeKey, Trade> cache = ignite.getOrCreateCache("MyCache");
>
> Trade trade1 = new Trade();
> trade1.setId(1);
> trade1.setSize(10);
> cache.put(new TradeKey(trade.getId()), trade1);
> // event is generated
> //evt.oldValue is null, no problem
> trade1 = cache.get(new TradeKey(1)); // or could be a query or any search
> on
> the cache
> trade1.setSize(20);
> cache.put(new TradeKey(trade.getId()),trade1);
> // event is generated
> // evt.oldValue().getSize() is 20, evt.newValue().getSize() is 20, this is
> BAD
>
> Any advice? Thanks.
>
>
>
> --
> View this message in context: http://apache-ignite-users.
> 70518.x6.nabble.com/Grid-Events-and-oldValue-versus-newValue-tp10577.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>



-- 
Best regards,
Andrey V. Mashenkov

Reply via email to