Repository navigation
feat(cache)!: the cache runs from its config, not CACHE_DRIVER - #14
Closed
arjendevos wants to merge 5 commits into
Closed
arjendevos wants to merge 5 commits into
arjendevos wants to merge 5 commits into
Conversation
The cache read CACHE_DRIVER from the environment, and queueing and the rate-limit middleware each built a cache of their own. A cache now takes config.Cache through cache.WithConfig, and one used without it fails with ErrNoConfig; the Redis driver uses the connection the config names. Queueing debounces in the app's cache (queueing.WithCache, which app.WithQueueing passes), and rate-limited jobs count in it (middleware.UseCache, which app.New calls). BREAKING CHANGE: a cache needs cache.WithConfig, cache.NewEngine and queueing.NewEngine take the config and the cache, and NewRedis takes a connection name.
Contributor
Author
|
Folded into #18. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #13.
The cache read
CACHE_DRIVERfrom the environment, and queueing and the rate-limit middleware each built a cache of their own withcache.New().config.Cachethroughcache.WithConfig. One used without it fails at the first use, so an app that never uses the cache needs none; an unknown driver is an error rather than a nil resolver.Connection), the default one when empty.queueing.WithCache, whichapp.WithQueueingpasses.middleware.UseCache, whichapp.Newcalls. Until then the limiter fails open, as it did on a cache error.Breaking: a cache needs
cache.WithConfig(CACHE_DRIVERis no longer read),cache.NewEngineandqueueing.NewEnginetake the config and the cache, andresolvers.NewRedistakes a connection name.Tested:
tests/cachecovers a cache without config, an unknown driver and the memory driver; the ratelimit test (moved undertests/ratelimit) runs on a configured memory cache.