Files
36Wisdom/common/content_cache.go
T
2026-08-14 16:11:10 +08:00

18 lines
524 B
Go

package common
import (
"context"
"github.com/gogf/gf/v2/frame/g"
)
// InvalidateContentCache 内容写操作提交后统一失效查询缓存(技术设计.md 4.17)。
// 表名由调用方(service 层)传入:gdb 缓存 key 按表名前缀组织,ClearCache 按表批量删除,
// 后台改内容、前台读缓存立即取新值,无需等待 TTL。
func InvalidateContentCache(ctx context.Context, tables ...string) {
core := g.DB().GetCore()
for _, t := range tables {
core.ClearCache(ctx, t)
}
}