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

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: Fix GetMetaDefault silliness 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 » » v, err := ds.GetMetaDefault(mg, CacheEnableMeta, true)
47 » » if err != nil {
48 » » » // TODO(riannucci): Not sure what to do with this
49 » » » panic(err)
50 » » }
51 » » if !v.(bool) {
46 continue 52 continue
47 } 53 }
48 shards := s.numShards(key) 54 shards := s.numShards(key)
49 if shards == 0 { 55 if shards == 0 {
50 continue 56 continue
51 } 57 }
52 if ret == nil { 58 if ret == nil {
53 ret = make([]string, len(keys)) 59 ret = make([]string, len(keys))
54 } 60 }
55 ret[i] = MakeMemcacheKey(s.mr.Intn(shards), key) 61 ret[i] = MakeMemcacheKey(s.mr.Intn(shards), key)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 return nil, nil 155 return nil, nil
150 } 156 }
151 ret := make([]memcache.Item, len(mcKeys)) 157 ret := make([]memcache.Item, len(mcKeys))
152 for i := range ret { 158 for i := range ret {
153 ret[i] = (s.mc.NewItem(mcKeys[i]). 159 ret[i] = (s.mc.NewItem(mcKeys[i]).
154 SetFlags(uint32(ItemHasLock)). 160 SetFlags(uint32(ItemHasLock)).
155 SetExpiration(time.Second * time.Duration(LockTimeSecond s))) 161 SetExpiration(time.Second * time.Duration(LockTimeSecond s)))
156 } 162 }
157 return ret, mcKeys 163 return ret, mcKeys
158 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698