mjibson/goon — pull request #27 by mzimmerman (2014-02-06 13:16:31+00:00)
Title: Application code should not be able to modify locacl cache except through Put/Get

In the current scheme, we're storing Put and Get objects in local cache, often struct pointers. If an application does a Put/Get and then modifies a field in their struct for some local processing, the struct in local cache gets updated too (since it's the same one). That wouldn't necessarily be a problem if the application then does a Put to save the changes, but that's not a requirement. The application may want to use it for some temporary processing since the object was already allocated. Temporary processing doesn't change the data in the datastore (and hence it shouldn't change it in goon either). Temporary p

This change stores whatever the native format of the request is into cache. That is, if the object is a struct pointer, a new allocation occurs, and the data is populated. If the object is a struct, then assignment by value naturally stores a copy.

When retrieving from the local cache we also have to make a copy, otherwise any temporary calculations without a Put request would update the local cache as well.