Comments (4)
I've been looking at this and have learned a few things. Your test case is correctly identifying a bug. GetMulti, which is in charge of populating the result data, is correctly identifying this key as in memory (which is why it's returning 0 instead of 15, which it would if it had to go to memcache/datastore). However, instead of using the existing memory provided by goonPutGet, it is assigning over its location in the slice.
Get is a wrapper for GetMulti. I've modified your test to use v := []interface{}{goonPutGet}
and call GetMulti(v)
. After the call, goonPutGet remains the same, but v
now contains the data with a value of 15. So it's doing v[0] = <struct from memory cache>
instead of populating the members of v[0]
with the data from the cache.
The existing behavior has a nice speed and pointer benefit: the new v[0]
points to the same data as is in the cache, which means modifying it in one place modifies it in all of them. I think that's good and expected. Doing something where we instead copy all of the data from the cached value into v[0]
(and thus into goonPutGet) loses this feature. But, changing to the former behavior would mean changing the API (and drifting from the datastore API), which is worse.
So, the cache must always copy its contents to the destination instead of point the slice to the value. I'll work on that. Thanks for being a rubber duck.
from goon.
Thanks for the explanation. I also learnt a few things!
from goon.
I had fixed this in my fork with revision 530e947
The key line is set.Elem().Set(reflect.ValueOf(dsts[0]).Elem())
which equates to *dst = *dsts[0]
from goon.
This was fixed in #13 and can be closed.
from goon.
Related Issues (20)
- Adding a property to an entity HOT 1
- Expose Underlying Context in Goon type? HOT 4
- laterGet and laterPut HOT 5
- Consistency issue using aetest HOT 10
- Documentation appstats usage HOT 2
- Adding a Put to memory only call HOT 3
- Add support for google.golang.org/appengine packages HOT 18
- Can code depending on goon be unit tested without devserver? HOT 2
- Changes by PropertyLoadSaver.Load aren't cached. HOT 5
- Using context.Context in place of *http.Request HOT 5
- Use FromGoon in docs
- What's license? HOT 2
- TestEmbeddedStruct fails HOT 2
- GetMulti and Get don't ignore field mismatch in Tx HOT 2
- Failed to decode field config - extra data in buffer HOT 3
- Make compatible with cloud.google.com/go HOT 9
- Why the name `goon`? HOT 2
- Reusing entity cause slice values to be appended HOT 2
- Request: Add release tag for go modules HOT 3
- Surface a way to know the final cache key of entities. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goon.