feat(19.3-04): cooler site-cache purge service with site_cache.purge_url and purge_token
- cooler.SiteCachePurger moved from the Journal plugin: loopback-only http, 32-character token, 2 s detached request, no token in logs or errors - NewSiteCachePurgerFor names caller keys (for plugin alias keys) - PurgeSiteCacheAfterCommit through lagoon.AfterCommit, one POST per save - SiteCacheFromApp for hooks outside serve; Install publishes the purger unless a plugin already did, and fails boot on an invalid config - caching docs section, cooler README, configuration row
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
// Package cooler holds the shared-state services of a SummerCMS application:
|
||||
// a Laravel-core Cache with a memory (otter) and a Redis driver under a
|
||||
// per-application key prefix, and a Redis-backed fixed-window rate-limit
|
||||
// store that keeps limits across application instances. One redis.url key
|
||||
// configures Redis for both. The framework installs cooler at boot (surf's
|
||||
// serve command) and FromApp serves other commands, so applications import
|
||||
// nothing.
|
||||
// per-application key prefix, a Redis-backed fixed-window rate-limit
|
||||
// store that keeps limits across application instances, and the site-cache
|
||||
// purge that asks the host site to drop its page caches after admin saves.
|
||||
// One redis.url key configures Redis for the cache and the store. The
|
||||
// framework installs cooler at boot (surf's serve command) and FromApp and
|
||||
// SiteCacheFromApp serve other commands, so applications import nothing.
|
||||
//
|
||||
// cooler imports neither surf nor cabana: surf imports cooler, and the
|
||||
// rate-limit store satisfies surf.Store structurally through Attempter.
|
||||
@@ -153,6 +154,11 @@ func (h *Handle) RateLimitStore(fallback Attempter) Attempter {
|
||||
// answers. A missing or invalid redis.url, an unknown driver name or a
|
||||
// non-positive cache.memory.max_entries is a boot error naming the key.
|
||||
//
|
||||
// Install also publishes the site-cache purger (SiteCachePurger) built from
|
||||
// site_cache.purge_url and site_cache.purge_token, unless a plugin already
|
||||
// published one; an invalid site_cache configuration is a boot error naming
|
||||
// the key, and an enabled purger is logged with its Endpoint.
|
||||
//
|
||||
// Only the serve command calls Install; route:list and tests never dial Redis.
|
||||
func Install(ctx context.Context, app *backpack.App) (*Handle, error) {
|
||||
if app == nil {
|
||||
@@ -163,6 +169,9 @@ func Install(ctx context.Context, app *backpack.App) (*Handle, error) {
|
||||
}
|
||||
cfg := app.Config
|
||||
h := &Handle{prefix: keyPrefix(cfg), log: loggerFromApp(app)}
|
||||
if err := installSiteCache(app, h.log); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
store, err := driverName(cfg, RateLimitStoreKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user