Closed Blackclaws closed 4 years ago
This is what happens with any in-memory based caching - you are caching the actual reference to the object in-memory, the object does not get serialised or persisted anywhere magically - that is why it is usually the fasted type of cache. To avoid you would need to do some form of object cloning before you cached it. In your example the second instance is never used, because the first instance is in the cache. Would some improved documentation help?
@alastairtree
Hi, i just ran into this issue and was able to figure out after an hour of debugging. It would be very useful to have it documented :)
Added a new Troubleshooting docs page to cover this scenario. Thanks for getting in touch.
LazyCache persists changes to reference objects into the cache.
This, if not avoidable (very unlikely as objects would have to be copyable which is not a given), should at least be documented somewhere as a potential caveat.
Find an example application below:
Expected result:
"Not Set" "Changed" "Not Set" "Exiting"
Result:
"Not Set" "Changed" "Changes" "Exiting"