Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The LUCI Authors. All rights reserved. | |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | |
| 3 // that can be found in the LICENSE file. | |
| 4 | |
| 5 package config | |
| 6 | |
| 7 import ( | |
| 8 "time" | |
| 9 | |
| 10 "github.com/luci/luci-go/luci_config/server/cfgclient/backend" | |
| 11 "github.com/luci/luci-go/luci_config/server/cfgclient/backend/caching" | |
| 12 | |
| 13 "golang.org/x/net/context" | |
| 14 ) | |
| 15 | |
| 16 // CacheOptions is the set of configuration options. | |
| 17 type CacheOptions struct { | |
| 18 // CacheExpiration is the amount of time that a config entry should be c ached. | |
| 19 CacheExpiration time.Duration | |
|
iannucci
2017/01/21 00:23:13
a negative (or 0?) value has no effect
dnj
2017/01/21 01:37:31
Done.
| |
| 20 } | |
| 21 | |
| 22 // WrapBackend wraps the supplied backend with caching as appropriately | |
| 23 // configured. | |
|
iannucci
2017/01/21 00:23:13
Maybe:
WrapBackend updates the context with a n
dnj
2017/01/21 01:37:31
Done.
| |
| 24 func (o *CacheOptions) WrapBackend(c context.Context, base backend.B) context.Co ntext { | |
| 25 return backend.WithFactory(c, func(c context.Context) backend.B { | |
| 26 // Start with our base Backend. | |
| 27 be := base | |
| 28 | |
| 29 // Add a proccache-based config cache. | |
| 30 if o.CacheExpiration > 0 { | |
|
iannucci
2017/01/21 00:23:13
== 0 could be problematic... I'd skip proccache in
dnj
2017/01/21 01:37:31
Done.
| |
| 31 be = caching.ProcCache(be, o.CacheExpiration) | |
| 32 } | |
| 33 | |
| 34 return be | |
| 35 }) | |
| 36 } | |
| OLD | NEW |