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

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

Issue 1355783002: Refactor keys and queries in datastore service and implementation. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: appease errcheck Created 5 years, 3 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
« no previous file with comments | « filter/count/rds.go ('k') | filter/dscache/ds.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package dscache 5 package dscache
6 6
7 import ( 7 import (
8 ds "github.com/luci/gae/service/datastore" 8 ds "github.com/luci/gae/service/datastore"
9 "github.com/luci/gae/service/info" 9 "github.com/luci/gae/service/info"
10 mc "github.com/luci/gae/service/memcache" 10 mc "github.com/luci/gae/service/memcache"
(...skipping 10 matching lines...) Expand all
21 // shardsForKey is a user-controllable function which calculates the number of 21 // shardsForKey is a user-controllable function which calculates the number of
22 // shards to use for a certain datastore key. The provided key will always be 22 // shards to use for a certain datastore key. The provided key will always be
23 // valid and complete. 23 // valid and complete.
24 // 24 //
25 // The # of shards returned may be between 1 and 256. Values above this range 25 // The # of shards returned may be between 1 and 256. Values above this range
26 // will be clamped into that range. A return value of 0 means that NO cache 26 // will be clamped into that range. A return value of 0 means that NO cache
27 // operations should be done for this key, regardless of the dscache.enable 27 // operations should be done for this key, regardless of the dscache.enable
28 // setting. 28 // setting.
29 // 29 //
30 // If shardsForKey is nil, the value of DefaultShards is used for all keys. 30 // If shardsForKey is nil, the value of DefaultShards is used for all keys.
31 func FilterRDS(c context.Context, shardsForKey func(ds.Key) int) context.Context { 31 func FilterRDS(c context.Context, shardsForKey func(*ds.Key) int) context.Contex t {
32 if !IsGloballyEnabled(c) { 32 if !IsGloballyEnabled(c) {
33 return c 33 return c
34 } 34 }
35 35
36 return ds.AddRawFilters(c, func(c context.Context, ds ds.RawInterface) d s.RawInterface { 36 return ds.AddRawFilters(c, func(c context.Context, ds ds.RawInterface) d s.RawInterface {
37 i := info.Get(c) 37 i := info.Get(c)
38 38
39 sc := &supportContext{ 39 sc := &supportContext{
40 i.AppID(), 40 i.AppID(),
41 i.GetNamespace(), 41 i.GetNamespace(),
42 c, 42 c,
43 mc.Get(c), 43 mc.Get(c),
44 mathrand.Get(c), 44 mathrand.Get(c),
45 shardsForKey, 45 shardsForKey,
46 } 46 }
47 47
48 v := c.Value(dsTxnCacheKey) 48 v := c.Value(dsTxnCacheKey)
49 if v == nil { 49 if v == nil {
50 return &dsCache{ds, sc} 50 return &dsCache{ds, sc}
51 } 51 }
52 return &dsTxnCache{ds, v.(*dsTxnState), sc} 52 return &dsTxnCache{ds, v.(*dsTxnState), sc}
53 }) 53 })
54 } 54 }
OLDNEW
« no previous file with comments | « filter/count/rds.go ('k') | filter/dscache/ds.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698