Merge pull request #40 from icholy/master

Fix example in README
This commit is contained in:
Derrick J. Wippler 2022-05-17 14:35:05 -05:00 committed by GitHub
commit fa08e0059d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}, },
)) ))