Index: impl/memory/datastore.go |
diff --git a/impl/memory/datastore.go b/impl/memory/datastore.go |
index 5b8581a71c8d9e6c3623086b949c3b7b613784dd..efc61d3ba5f1a13ee1ac6bc8c89a04c206a508c9 100644 |
--- a/impl/memory/datastore.go |
+++ b/impl/memory/datastore.go |
@@ -11,6 +11,7 @@ import ( |
"golang.org/x/net/context" |
ds "github.com/luci/gae/service/datastore" |
+ "github.com/luci/gae/service/info" |
) |
//////////////////////////////////// public //////////////////////////////////// |
@@ -29,6 +30,29 @@ func useRDS(c context.Context) context.Context { |
}) |
} |
+// NewDatastore creates a new standalone memory implementation of the datastore, |
+// suitable for embedding for doing in-memory data organization. |
+// |
+// It's configured by default with the following settings: |
+// * AutoIndex(true) |
+// * Consistent(true) |
+// * DisableSpecialEntities(true) |
+// |
+// These settings can of course be changed by using the Testable() interface. |
+func NewDatastore(aid, ns string) (ds.Interface, error) { |
+ ctx := UseWithAppID(context.Background(), aid) |
+ ctx, err := info.Get(ctx).Namespace(ns) |
+ if err != nil { |
+ return nil, err |
+ } |
+ ret := ds.Get(ctx) |
+ t := ret.Testable() |
Vadim Sh.
2015/09/29 20:08:36
name 'Testable' is unfortunate, considering it is
iannucci
2015/09/29 20:09:45
Yeah that occurred to me. AlterSemantics?
Vadim Sh.
2015/09/29 20:12:03
"Tweaks"? "Hacks"? :)
|
+ t.AutoIndex(true) |
+ t.Consistent(true) |
+ t.DisableSpecialEntities(true) |
+ return ret, nil |
+} |
+ |
//////////////////////////////////// dsImpl //////////////////////////////////// |
// dsImpl exists solely to bind the current c to the datastore data. |