Okay guys… let me try to explain this clearly. Im sorry its so confusing… but anyalternate models we coudl come up with that didnt have really vicious over-head were even more confusing…
There is always a value in the object store to be PEEked. It is the last comitted value of the object.
This does not change until a transaction that has done a GET on the object, and subsequently modified it, commits.
At that point there is a new value to be PEEKed in the object store.
Now inside of a single transaction, what happens on GET and PEEk is kind of important to completing the story so heres how it works:
When you PEEK the first time, you get a refernce to an object that is a copy of that state in the object store.
Subsequent PEEKs will return a reference to that same object. Even if another transaction comes ina nd commits a new value,
you won’t see it because you arelady have a peek-copy locally.
The one time this chnages is when you do a GET. When you do a GET the first time, a new object representing a copy of the current state in the object store is made at the same time the GET-lock is taken.
After this, any subsequent GETs return a reference to that copy.
ALSO after that GET any subsequent PEEKs return a reference to the copy returned by GET… even if you did a PEEK before the GET.
That last line is the sort-of-tricky part. But it really does result in the code doing “what yo uwant” in an intuitive manner the vast majority of times.