- classes.SiteCachePurger, NewSiteCachePurger, PurgeSiteCacheAfterCommit and the key and limit constants stay as deprecated aliases for one release - wireSiteCache: framework keys site_cache.* win (Journal keys ignored with a warning); with only golem15.journal.site_cache.* set it publishes the purger from them with a deprecation warning, so menu and FAQ saves purge through it too - controllers take the purger from cooler.SiteCacheFromApp - TestSiteCacheFrameworkKeysWin; README documents both key sets
37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
package controllers
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.golem15.com/golem15/sm-journal-plugin/classes"
|
|
"git.golem15.com/golem15/summercms/modules/backpack"
|
|
"git.golem15.com/golem15/summercms/modules/cabana"
|
|
"git.golem15.com/golem15/summercms/modules/cooler"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// siteCachePurger returns the application's site-cache purger
|
|
// (cooler.SiteCacheFromApp: the framework keys, or the purger the plugin
|
|
// published from its deprecated keys) and the save transaction of ctx, for
|
|
// classes.PurgeSiteCacheAfterCommit. Without a purger (no purge configured)
|
|
// or outside a save transaction it returns a nil purger, which
|
|
// PurgeSiteCacheAfterCommit ignores.
|
|
func siteCachePurger(ctx context.Context, app func() *backpack.App) (*classes.SiteCachePurger, *gorm.DB) {
|
|
if app == nil {
|
|
return nil, nil
|
|
}
|
|
a := app()
|
|
if a == nil {
|
|
return nil, nil
|
|
}
|
|
tx, ok := cabana.TxFromContext(ctx)
|
|
if !ok {
|
|
return nil, nil
|
|
}
|
|
purger := cooler.SiteCacheFromApp(a)
|
|
if purger == nil {
|
|
return nil, nil
|
|
}
|
|
return purger, tx
|
|
}
|