Last active
December 2, 2018 06:32
-
-
Save timakin/078a2fd88463d8c2bffe63c311811454 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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