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

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

Issue 1516173002: Fix error message from KeyForObj when passing an invalid struct. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: remove accidental extra test Created 5 years 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
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 "fmt" 8 "fmt"
9 "math/rand" 9 "math/rand"
10 "time" 10 "time"
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 if ret > MaxShards { 36 if ret > MaxShards {
37 ret = MaxShards 37 ret = MaxShards
38 } 38 }
39 return ret 39 return ret
40 } 40 }
41 41
42 func (s *supportContext) mkRandKeys(keys []*ds.Key, metas ds.MultiMetaGetter) [] string { 42 func (s *supportContext) mkRandKeys(keys []*ds.Key, metas ds.MultiMetaGetter) [] string {
43 ret := []string(nil) 43 ret := []string(nil)
44 for i, key := range keys { 44 for i, key := range keys {
45 » » if !metas.GetMetaDefault(i, CacheEnableMeta, true).(bool) { 45 » » mg := metas.GetSingle(i)
46 » » if !ds.GetMetaDefault(mg, CacheEnableMeta, true).(bool) {
46 continue 47 continue
47 } 48 }
48 shards := s.numShards(key) 49 shards := s.numShards(key)
49 if shards == 0 { 50 if shards == 0 {
50 continue 51 continue
51 } 52 }
52 if ret == nil { 53 if ret == nil {
53 ret = make([]string, len(keys)) 54 ret = make([]string, len(keys))
54 } 55 }
55 ret[i] = MakeMemcacheKey(s.mr.Intn(shards), key) 56 ret[i] = MakeMemcacheKey(s.mr.Intn(shards), key)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 return nil, nil 150 return nil, nil
150 } 151 }
151 ret := make([]memcache.Item, len(mcKeys)) 152 ret := make([]memcache.Item, len(mcKeys))
152 for i := range ret { 153 for i := range ret {
153 ret[i] = (s.mc.NewItem(mcKeys[i]). 154 ret[i] = (s.mc.NewItem(mcKeys[i]).
154 SetFlags(uint32(ItemHasLock)). 155 SetFlags(uint32(ItemHasLock)).
155 SetExpiration(time.Second * time.Duration(LockTimeSecond s))) 156 SetExpiration(time.Second * time.Duration(LockTimeSecond s)))
156 } 157 }
157 return ret, mcKeys 158 return ret, mcKeys
158 } 159 }
OLDNEW
« no previous file with comments | « filter/dscache/ds.go ('k') | filter/txnBuf/txnbuf_test.go » ('j') | service/datastore/pls.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698