mirror of
https://github.com/mailgun/groupcache.git
synced 2024-11-16 14:10:04 +00:00
commit
fa08e0059d
@ -122,15 +122,13 @@ func ExampleUsage() {
|
|||||||
func(ctx context.Context, id string, dest groupcache.Sink) error {
|
func(ctx context.Context, id string, dest groupcache.Sink) error {
|
||||||
|
|
||||||
// Returns a protobuf struct `User`
|
// Returns a protobuf struct `User`
|
||||||
if user, err := fetchUserFromMongo(ctx, id); err != nil {
|
user, err := fetchUserFromMongo(ctx, id)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the user in the groupcache to expire after 5 minutes
|
// Set the user in the groupcache to expire after 5 minutes
|
||||||
if err := dest.SetProto(&user, time.Now().Add(time.Minute*5)); err != nil {
|
return dest.SetProto(&user, time.Now().Add(time.Minute*5))
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user