On Apr 21, 2009, at 11:40 PM, Ylan Segal wrote:
> In a web app where each session has a DataContext, do I need to
> worry about data caching in different DataContexts? I don't know if
> that is clear, so let me explain. Suppose we are talking about a pet
> store. User A and B are both separately
> in their browser shopping for a cat. There is only 1 left in
> inventory. Both user A and B see that there is one left. User A
> makes up his mind first and buys the cat. The changes are committed.
> In the DB the inventory correctly has the number of cats at 0. If
> User B's DataContext caches the data, it might think that the
> inventory is still 1 and also allow User B to buy the cat. Should I
> worry about this or is it all taken care of by Cayenne?
Changes are automatically propagated on commit between all contexts
attached to the same Cayenne stack (usually all contexts in the same
VM). There are cross-VM notification mechanisms as well, although I
personally prefer to use optimistic locking and lazy cache refresh in
such cases (http://markmail.org/message/x4qauytoxfec7wup)
Andrus
This archive was generated by hypermail 2.0.0 : Tue Apr 21 2009 - 16:59:10 EDT