Code Monkey home page Code Monkey logo

Comments (14)

derekperkins avatar derekperkins commented on May 24, 2024

If I'm using PropertyLoadSaver, will that invalidate my cache?

from nds.

jongillham avatar jongillham commented on May 24, 2024

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.

derekperkins avatar derekperkins commented on May 24, 2024

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.

jongillham avatar jongillham commented on May 24, 2024

Commit 03e5a51 adds PropertyLoadSaver support.
The github.com/qedus/nds API now supports everything the appengine/datastore API does.

from nds.

derekperkins avatar derekperkins commented on May 24, 2024

Awesome, thanks! Can't wait to test it out!

from nds.

jongillham avatar jongillham commented on May 24, 2024

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.

derekperkins avatar derekperkins commented on May 24, 2024

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.

derekperkins avatar derekperkins commented on May 24, 2024

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.

jongillham avatar jongillham commented on May 24, 2024

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.

derekperkins avatar derekperkins commented on May 24, 2024

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.

jongillham avatar jongillham commented on May 24, 2024

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.

derekperkins avatar derekperkins commented on May 24, 2024

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.

jongillham avatar jongillham commented on May 24, 2024

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.

derekperkins avatar derekperkins commented on May 24, 2024

Good move. Now everything that is public replaces an existing datastore.Function(). Thanks for getting that done so quickly.

from nds.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.