@@ -25,6 +25,7 @@ limitations under the License.
25
25
package groupcache
26
26
27
27
import (
28
+ "context"
28
29
"errors"
29
30
"math/rand"
30
31
"strconv"
@@ -44,13 +45,13 @@ type Getter interface {
44
45
// uniquely describe the loaded data, without an implicit
45
46
// current time, and without relying on cache expiration
46
47
// mechanisms.
47
- Get (ctx Context , key string , dest Sink ) error
48
+ Get (ctx context. Context , key string , dest Sink ) error
48
49
}
49
50
50
51
// A GetterFunc implements Getter with a function.
51
- type GetterFunc func (ctx Context , key string , dest Sink ) error
52
+ type GetterFunc func (ctx context. Context , key string , dest Sink ) error
52
53
53
- func (f GetterFunc ) Get (ctx Context , key string , dest Sink ) error {
54
+ func (f GetterFunc ) Get (ctx context. Context , key string , dest Sink ) error {
54
55
return f (ctx , key , dest )
55
56
}
56
57
@@ -204,7 +205,7 @@ func (g *Group) initPeers() {
204
205
}
205
206
}
206
207
207
- func (g * Group ) Get (ctx Context , key string , dest Sink ) error {
208
+ func (g * Group ) Get (ctx context. Context , key string , dest Sink ) error {
208
209
g .peersOnce .Do (g .initPeers )
209
210
g .Stats .Gets .Add (1 )
210
211
if dest == nil {
@@ -233,7 +234,7 @@ func (g *Group) Get(ctx Context, key string, dest Sink) error {
233
234
}
234
235
235
236
// load loads key either by invoking the getter locally or by sending it to another machine.
236
- func (g * Group ) load (ctx Context , key string , dest Sink ) (value ByteView , destPopulated bool , err error ) {
237
+ func (g * Group ) load (ctx context. Context , key string , dest Sink ) (value ByteView , destPopulated bool , err error ) {
237
238
g .Stats .Loads .Add (1 )
238
239
viewi , err := g .loadGroup .Do (key , func () (interface {}, error ) {
239
240
// Check the cache again because singleflight can only dedup calls
@@ -292,15 +293,15 @@ func (g *Group) load(ctx Context, key string, dest Sink) (value ByteView, destPo
292
293
return
293
294
}
294
295
295
- func (g * Group ) getLocally (ctx Context , key string , dest Sink ) (ByteView , error ) {
296
+ func (g * Group ) getLocally (ctx context. Context , key string , dest Sink ) (ByteView , error ) {
296
297
err := g .getter .Get (ctx , key , dest )
297
298
if err != nil {
298
299
return ByteView {}, err
299
300
}
300
301
return dest .view ()
301
302
}
302
303
303
- func (g * Group ) getFromPeer (ctx Context , peer ProtoGetter , key string ) (ByteView , error ) {
304
+ func (g * Group ) getFromPeer (ctx context. Context , peer ProtoGetter , key string ) (ByteView , error ) {
304
305
req := & pb.GetRequest {
305
306
Group : & g .name ,
306
307
Key : & key ,
0 commit comments