Skip to content

feat(cache)!: the cache runs from its config, not CACHE_DRIVER - #14

Closed
arjendevos wants to merge 5 commits into
feat/app-configfrom
feat/cache-config
Closed

arjendevos wants to merge 5 commits into
feat/app-configfrom
feat/cache-config

Conversation

@arjendevos

@arjendevos arjendevos commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #13.

The cache read CACHE_DRIVER from the environment, and queueing and the rate-limit middleware each built a cache of their own with cache.New().

app.WithCache(cache.WithConfig(config.Cache{Driver: config.RedisCacheDriver}))
  • A cache takes config.Cache through cache.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.
  • The Redis driver uses the connection the config names (Connection), the default one when empty.
  • Queueing debounces in the app's cache: queueing.WithCache, which app.WithQueueing passes.
  • Rate-limited jobs count in it: middleware.UseCache, which app.New calls. Until then the limiter fails open, as it did on a cache error.

Breaking: a cache needs cache.WithConfig (CACHE_DRIVER is no longer read), cache.NewEngine and queueing.NewEngine take the config and the cache, and resolvers.NewRedis takes a connection name.

Tested: tests/cache covers a cache without config, an unknown driver and the memory driver; the ratelimit test (moved under tests/ratelimit) runs on a configured memory cache.

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.

Copy link
Copy Markdown
Contributor Author

Folded into #18.

@arjendevos arjendevos closed this Nov 23, 2026
@arjendevos
arjendevos deleted the feat/cache-config branch November 23, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant