Skip to content

Instantly share code, notes, and snippets.

@timakin
Last active December 2, 2018 06:32
Show Gist options
  • Save timakin/078a2fd88463d8c2bffe63c311811454 to your computer and use it in GitHub Desktop.
Save timakin/078a2fd88463d8c2bffe63c311811454 to your computer and use it in GitHub Desktop.
func DatastoreWithContext(ctx context.Context) context.Context {
ds, err := aedatastore.FromContext(ctx)
if err != nil {
panic(err)
}
ds.AppendMiddleware(localcache.New(
localcache.WithLogger(func(ctx context.Context, format string, args ...interface{}) {
fmt.Println(fmt.Sprintf(format, args...))
}),
localcache.WithExpireDuration(3*time.Minute),
))
ds.AppendMiddleware(aememcache.New(
aememcache.WithLogger(func(ctx context.Context, format string, args ...interface{}) {
fmt.Println(fmt.Sprintf(format, args...))
}),
aememcache.WithExpireDuration(15*time.Minute),
))
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment