Comments (14)
If I'm using PropertyLoadSaver, will that invalidate my cache?
from nds.
Unfortunately the API will currently reject anything that implement the PropertyLoadSaver. I'll have a go at implementing PLS functionality if it would be beneficial to you although I have held off because the new version of the App Engine API that works managed VMs has a different PLS interface. I have been waiting to see when/if it is ported to the standard App Engine runtime.
from nds.
That would be very helpful, as we use it all over. David Symonds has mentioned a few times about how he regrets the implementation of PropertyLoadSaver, but I question how soon that will actually change given their commitment to backwards compatibility.
from nds.
Commit 03e5a51 adds PropertyLoadSaver support.
The github.com/qedus/nds
API now supports everything the appengine/datastore
API does.
from nds.
Awesome, thanks! Can't wait to test it out!
from nds.
Please do. The trickiest part was catering for the numerous different ways slices of entities can be represented in GetMulti
and PutMulti
. PropertyLoadSaver
added a whole extra set of permutations. The unit tests weeded out issues with as many as I could think of.
from nds.
Great. My main use cases for PropertyLoadSaver are:
- Taking nested slices and gob encoding/decoding them as they go in and out of datastore
- Choosing whether or not to index specific fields / records
from nds.
Ok, your implementation as written appears to be for the Managed VM version of the datastore API, not appengine/datastore (https://godoc.org/code.google.com/p/appengine-go/appengine/datastore)
LoadStruct and SaveStruct are looking for a channel of Properties, not a PropertyList.
func SaveStruct(src interface{}, c chan<- Property) error
Any thoughts on how to get around this?
from nds.
Those nds.LoadStruct
and nds.SaveStruct
functions shouldn't have any impact on on using PropertyLoadSaver
. They are just internal helper functions that I found so useful that I made them public.
Please let me know if you have any issues using datastore.LoadStruct
and datastore.SaveStruct
with the package.
from nds.
I agree that those functions are very useful, and I'm using those functions quite extensively in my code. :) They are referenced in the datastore package documentation as a part of the external API.
type CustomPropsExample struct {
I, J int
// Sum is not stored, but should always be equal to I + J.
Sum int `datastore:"-"`
}
func (x *CustomPropsExample) Load(c <-chan Property) error {
// Load I and J as usual.
if err := datastore.LoadStruct(x, c); err != nil {
return err
}
// Derive the Sum field.
x.Sum = x.I + x.J
return nil
}
func (x *CustomPropsExample) Save(c chan<- Property) error {
defer close(c)
// Validate the Sum field.
if x.Sum != x.I + x.J {
return errors.New("CustomPropsExample has inconsistent sum")
}
// Save I and J as usual. The code below is equivalent to calling
// "return datastore.SaveStruct(x, c)", but is done manually for
// demonstration purposes.
c <- datastore.Property{
Name: "I",
Value: int64(x.I),
}
c <- datastore.Property{
Name: "J",
Value: int64(x.J),
}
return nil
}
from nds.
True, but you don't need to replace datastore.LoadStruct with nds.LoadStruct and datastore.SaveStruct with nds.SaveStruct. Maybe I should change them back to package private functions to save confusion?
On Tue, Oct 14, 2014 at 3:09 PM, Derek Perkins [email protected]
wrote:
Those functions are part of the external api for datastore that I'm using in a number of places. ?
Reply to this email directly or view it on GitHub:
#20 (comment)
from nds.
Sorry, I just edited my earlier comment because I accidentally posted it prematurely.
If that isn't going to affect the caching and shouldn't be used, then making the private would be a good idea. I haven't fully investigated, but when I did use datastore.LoadStruct and checked my appstats, it looked as though a call was still made to datastore.Get even on cache hit, making me think that those functions needed to be implemented.
from nds.
Commit 83e5c9d removes nds.LoadStruct
and nds.SaveStruct
for the time being to simplify the API and avoid confusion with datastore.LoadStruct
and datastore.SaveStruct
.
from nds.
Good move. Now everything that is public replaces an existing datastore.Function(). Thanks for getting that done so quickly.
from nds.
Related Issues (20)
- Remove zeroMemcache* code. HOT 1
- It is not possible to detect if nested contexts are transactional. HOT 5
- Make the transaction context safe for concurrent access. HOT 1
- Failing tests with "appengine: NewContext passed an unknown http.Request" HOT 2
- Different namespaces used for memcache and datastore HOT 4
- Migrating data when the underlying struct changes HOT 2
- Tests fail when using nds HOT 14
- nds item not stored warning HOT 4
- Calling AddMulti for a single entity instead of Add HOT 2
- Panic with datastore.PropertyLoadSaver HOT 3
- Make compatible with cloud.google.com/go HOT 8
- ErrFieldMismatch in GetMulti returns only one result HOT 4
- Gracefully handle memcache quota limits HOT 2
- Support saving of entities to memcache in putMulti() HOT 7
- Tag v2 branch as v2.0.0 HOT 3
- [v2] Possible marshal/unmarshaling bug HOT 2
- Change locking policy for Transaction HOT 1
- Change module versioning from git branches to subdirectories. HOT 2
- want new tag in v2 HOT 2
- failed to Put dial tcp 192.168.0.3:15127: connect: connection refused HOT 4
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 nds.