perf(config): add Otter RAM cache layer for system configs

Introduce pkg/cache/ram on top of existing Redis/DB config reads.
GetByKey now checks local RAM before Redis. Unified invalidation clears
RAM and Redis hash fields on admin writes, with pub/sub for multi-node
RAM eviction. Add tests and wire create/update/migrator write paths.
This commit is contained in:
ryan
2026-06-17 11:56:34 +08:00
parent ca21e0eca7
commit d3ba767087
16 changed files with 406 additions and 46 deletions
+1 -4
View File
@@ -69,10 +69,7 @@ func Migrate() {
}
func clearSystemConfigCache() {
if db.Redis == nil {
return
}
if err := db.Redis.Del(context.Background(), db.PrefixedKey(model.SystemConfigRedisHashKey)).Err(); err != nil {
if err := model.InvalidateAllSystemConfigCaches(context.Background()); err != nil {
log.Printf("[%s] clear system config cache failed: %v\n", dbType(), err)
}
}