Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: filter/dscache/context.go

Issue 1269113005: A transparent cache for datastore, backed by memcache. (Closed) Base URL: https://github.com/luci/gae.git@add_meta
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package dscache
6
7 import (
8 ds "github.com/luci/gae/service/datastore"
9 "github.com/luci/gae/service/info"
10 mc "github.com/luci/gae/service/memcache"
11 "github.com/luci/luci-go/common/logging"
12 "github.com/luci/luci-go/common/mathrand"
13 "golang.org/x/net/context"
14 )
15
16 type key int
17
18 var dsTxnCacheKey key
19
20 // FilterRDS installs a counter RawDatastore filter in the context.
21 func FilterRDS(c context.Context) context.Context {
22 return ds.AddRawFilters(c, func(ic context.Context, ds ds.RawInterface) ds.RawInterface {
23 i := info.Get(ic)
24 aid, ns := i.AppID(), i.GetNamespace()
25
26 v := ic.Value(dsTxnCacheKey)
27 if v == nil {
28 return &dsCache{ds, aid, ns, mc.Get(ic), logging.Get(ic) , mathrand.Get(ic)}
29 }
30 return &dsTxnCache{ds, v.(*dsTxnState), mc.Get(ic)}
31 })
32 }
OLDNEW
« no previous file with comments | « doc.go ('k') | filter/dscache/doc.go » ('j') | filter/dscache/dscache_test.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698