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

Side by Side Diff: appengine/datastorecache/cache.go

Issue 2617903005: Remove dsQueryBatch in favor of ds.Batcher. (Closed)
Patch Set: Created 3 years, 11 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 | « no previous file | appengine/datastorecache/manager.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 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package datastorecache 5 package datastorecache
6 6
7 import ( 7 import (
8 "math" 8 "math"
9 "strings" 9 "strings"
10 "time" 10 "time"
11 11
12 "github.com/luci/luci-go/appengine/memlock" 12 "github.com/luci/luci-go/appengine/memlock"
13 "github.com/luci/luci-go/common/clock" 13 "github.com/luci/luci-go/common/clock"
14 "github.com/luci/luci-go/common/data/rand/mathrand" 14 "github.com/luci/luci-go/common/data/rand/mathrand"
15 "github.com/luci/luci-go/common/errors" 15 "github.com/luci/luci-go/common/errors"
16 log "github.com/luci/luci-go/common/logging" 16 log "github.com/luci/luci-go/common/logging"
17 "github.com/luci/luci-go/common/retry" 17 "github.com/luci/luci-go/common/retry"
18 "github.com/luci/luci-go/server/router" 18 "github.com/luci/luci-go/server/router"
19 19
20 "github.com/luci/gae/impl/prod/constraints"
20 "github.com/luci/gae/service/datastore" 21 "github.com/luci/gae/service/datastore"
21 "github.com/luci/gae/service/info" 22 "github.com/luci/gae/service/info"
22 23
23 "golang.org/x/net/context" 24 "golang.org/x/net/context"
24 ) 25 )
25 26
26 const ( 27 const (
27 initialLoadLockRetries = 3 28 initialLoadLockRetries = 3
28 initialLoadDelay = 10 * time.Millisecond 29 initialLoadDelay = 10 * time.Millisecond
29 30
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 func (cache *Cache) pruneInterval() time.Duration { 169 func (cache *Cache) pruneInterval() time.Duration {
169 if cache.AccessUpdateInterval > 0 && cache.PruneFactor > 0 { 170 if cache.AccessUpdateInterval > 0 && cache.PruneFactor > 0 {
170 return cache.AccessUpdateInterval * time.Duration(1+cache.PruneF actor) 171 return cache.AccessUpdateInterval * time.Duration(1+cache.PruneF actor)
171 } 172 }
172 return 0 173 return 0
173 } 174 }
174 175
175 func (cache *Cache) manager() *manager { 176 func (cache *Cache) manager() *manager {
176 return &manager{ 177 return &manager{
177 cache: cache, 178 cache: cache,
178 » » queryBatchSize: managerQueryBatchSize, 179 » » queryBatchSize: constraints.DS().QueryBatchSize,
179 } 180 }
180 } 181 }
181 182
182 // InstallCronRoute installs a handler for this Cache's management cron task 183 // InstallCronRoute installs a handler for this Cache's management cron task
183 // into the supplied Router at the specified path. 184 // into the supplied Router at the specified path.
184 // 185 //
185 // It is recommended to assert in the middleware that this endpoint is only 186 // It is recommended to assert in the middleware that this endpoint is only
186 // accessible from a cron task. 187 // accessible from a cron task.
187 func (cache *Cache) InstallCronRoute(path string, r *router.Router, base router. MiddlewareChain) { 188 func (cache *Cache) InstallCronRoute(path string, r *router.Router, base router. MiddlewareChain) {
188 m := cache.manager() 189 m := cache.manager()
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 // delta is a factor representing the amount of time that it takes to 469 // delta is a factor representing the amount of time that it takes to
469 // recalculate the value. Higher delta values allow for earlier recomputation 470 // recalculate the value. Higher delta values allow for earlier recomputation
470 // for values that take longer to calculate. 471 // for values that take longer to calculate.
471 // 472 //
472 // beta can be set to >1 to favor earlier recomputations; however, in practice 473 // beta can be set to >1 to favor earlier recomputations; however, in practice
473 // beta=1 works well. 474 // beta=1 works well.
474 func xFetch(now, expiry time.Time, delta time.Duration, beta float64, rf randFun c) bool { 475 func xFetch(now, expiry time.Time, delta time.Duration, beta float64, rf randFun c) bool {
475 offset := time.Duration(float64(delta) * beta * math.Log(rf())) 476 offset := time.Duration(float64(delta) * beta * math.Log(rf()))
476 return !now.Add(-offset).Before(expiry) 477 return !now.Add(-offset).Before(expiry)
477 } 478 }
OLDNEW
« no previous file with comments | « no previous file | appengine/datastorecache/manager.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698