Categorygithub.com/bashtian/nds
modulepackage
2.0.3+incompatible
Repository: https://github.com/bashtian/nds.git
Documentation: pkg.go.dev

# README

nds (v2 - EXPERIMENTAL)

Build Status Coverage Status GoDoc

Package github.com/qedus/nds is a Google Cloud Datastore API for Go that uses a cache backend to cache all datastore requests. Memcache is only supported on Google AppEngine Standard, but the package can be used for any other implemented cache backend on any platform (local, Google Compute, AWS, etc.). This package guarantees strong cache consistency when using nds.Client.Get* and nds.Client.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 (code.google.com/go/datastore). However, underneath github.com/qedus/nds uses a caching stategy similar to the GAE Python NDB API. In fact the caching strategy used here even fixes one or two of the Python NDB caching consistency bugs.

You can find the API documentation at http://godoc.org/github.com/qedus/nds.

One other benefit is that the standard datastore.Client.GetMulti, datastore.Client.PutMulti and datastore.Client.DeleteMulti functions only allow you to work with a maximum of 1000, 500 and 500 entities per call respectively. The nds.Client.GetMulti, nds.Client.PutMulti and nds.Client.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 code.google.com/go/datastore.Client for methods provided by nds.Client. However, it is important that you use a nds.Client entirely within your code. Do not mix use of those functions with the code.google.com/go/datastore.Client equivalents as you will be liable to get stale datastore entities from github.com/qedus/nds.

Ultimately all you need to do is:

  • import github.com/qedus/nds/v2
  • use nds.NewClient instead of datastore.NewClient, providing a cache configuration to the new client creation function.
  • replace datastore.Transaction -> nds.Transaction
  • if using (*datastore.Query).Transaction for queries within transactions, switch to the (*nds.Transaction).Query helper.

# Packages

No description provided by the author

# Functions

NewClient will return an nds.Client that can be used exactly like a datastore.Client but will transparently use the cache configuration provided to cache requests when it can.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
WithOnErrorFunc sets up an OnErrorFunc to be called for every internal error that doesn't return to the caller but maybe useful to capture for logging/debugging/reporting purposes.

# Variables

Views.
ErrCacheMiss means an item was not found in cache.
ErrCASConflict means the cache item was modified between Get and CAS calls.
ErrNotStored means that an item was not stored due to a condition check failure (e.g.
Tag Keys.

# Structs

No description provided by the author
Item is the unit of Cacher gets and sets.
No description provided by the author
No description provided by the author

# Interfaces

Cacher represents a cache backend that can be used by nds.

# Type aliases

ClientOption is an option for a nds Client.
MultiError is returned by batch operations when there are errors with particular elements.
No description provided by the author