https://github.com/qedus/nds
A Go (golang) Google App Engine datastore package with strongly consistent caching.
https://github.com/qedus/nds
appengine datastore go memcache
Last synced: 11 months ago
JSON representation
A Go (golang) Google App Engine datastore package with strongly consistent caching.
- Host: GitHub
- URL: https://github.com/qedus/nds
- Owner: qedus
- License: apache-2.0
- Created: 2014-01-27T12:24:16.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2024-05-06T22:32:39.000Z (almost 2 years ago)
- Last Synced: 2025-04-30T15:23:31.717Z (11 months ago)
- Topics: appengine, datastore, go, memcache
- Language: Go
- Homepage: http://godoc.org/github.com/qedus/nds
- Size: 389 KB
- Stars: 147
- Watchers: 15
- Forks: 27
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nds
[](https://travis-ci.org/qedus/nds) [](https://coveralls.io/github/qedus/nds?branch=master) [](https://godoc.org/github.com/qedus/nds)
Package `github.com/qedus/nds` is a datastore API for the Google App Engine (GAE) [Go Runtime Environment](https://developers.google.com/appengine/docs/go/) that uses memcache to cache all datastore requests. It is compatible with both Classic and Managed VM products. This package guarantees strong cache consistency when using `nds.Get*` and `nds.Put*`, meaning you will never get data from a stale cache.
Exposed parts of this API are the same as the official one distributed by Google ([`google.golang.org/appengine/datastore`](https://godoc.org/google.golang.org/appengine/datastore)). However, underneath `github.com/qedus/nds` uses a caching stategy similar to the GAE [Python NDB API](https://developers.google.com/appengine/docs/python/ndb/). In fact the caching strategy used here even fixes one or two of the Python NDB [caching consistency bugs](http://goo.gl/3ByVlA).
You can find the API documentation at [http://godoc.org/github.com/qedus/nds](http://godoc.org/github.com/qedus/nds).
One other benefit is that the standard `datastore.GetMulti`, `datastore.PutMulti` and `datastore.DeleteMulti` functions only allow you to work with a maximum of 1000, 500 and 500 entities per call respectively. The `nds.GetMulti`, `nds.PutMulti` and `nds.DeleteMulti` functions in this package allow you to work with as many entities as you need (within timeout limits) by concurrently calling the appropriate datastore function until your request is fulfilled.
## How To Use
You can use this package in *exactly* the same way you would use [`google.golang.org/appengine/datastore`](https://godoc.org/google.golang.org/appengine/datastore). However, it is important that you use `nds.Get*`, `nds.Put*`, `nds.Delete*` and `nds.RunInTransaction` entirely within your code. Do not mix use of those functions with the `google.golang.org/appengine/datastore` equivalents as you will be liable to get stale datastore entities from `github.com/qedus/nds`.
Ultimately all you need to do is find/replace the following in your codebase:
- `datastore.Get` -> `nds.Get`
- `datastore.Put` -> `nds.Put`
- `datastore.Delete` -> `nds.Delete`
- `datastore.RunInTransaction` -> `nds.RunInTransaction`
## Versions
Versions are specified using [Go Modules](https://github.com/golang/go/wiki/Modules).
- Version 1.x.x: Can be found on branch [`master`](https://github.com/qedus/nds/tree/master) and uses the `google.golang.org/appengine` package.
- Version 2.x.x: Can be found on branch [`v2`](https://github.com/qedus/nds/tree/v2). This is a major update and takes advantage of the new `cloud.google.com/go/datastore` package provided by Google. It currently in an experimental state and we welcome contributions.