It seemed to me that I needed the same thing. So I created a package called:
Documentation | A source
go get github.com/scotch/aego/ds
It uses the same API as "appengine/datastore" , so it will work as a replacement.
import "github.com/scotch/aego/v1/ds" u = &User{Name: "Bob"} key := datastore.NewKey(c, "User", "bob", 0, nil) key, err := ds.Put(c, key, u) u = new(User) err = ds.Get(c, key, u)
By default, it caches all Put and Get in memcache, but you can change this behavior by calling the ds.Register method:
ds.Register("User", true, false, false)
The Register method takes a string representing Kind and 3 bool - userDatastore , useMemcache , useMemory . Passing true will cause AEgo/ds to keep the record in this repository. The Storage is useful for records that you do not expect to change, but may contain outdated data if you have more than one instance.
Supported Methods:
Put PutMulti Get GetMulti Delete DeleteMulti AllocateIDs
Note. Currently, cashing out occurs only with Get . GetMulti is retrieved from the data store.
AEgo/ds is work, but the code is well tested. Any feedback would be appreciated.
And to answer this question, how do I serialize entities for gob to save memcache.
Kyle finley
source share