Files
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

17 lines
740 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Package localcache 提供进程内一级缓存(基于 go-cache)。
//
// C 为包级变量,导入即就绪、永不为 nil,可被任意分层(common/models/app/web/skd
// 与任意二进制安全使用。此前各服务各自维护 appg.Cache / skdg.Cache,公共代码一旦
// 依赖某个具体服务的缓存全局变量,就会在未初始化该变量的进程(如 skd 调用 appg.Cache
// 中触发 nil panic。统一到本包后从根上消除该耦合。
package localcache
import (
"time"
"github.com/patrickmn/go-cache"
)
// C 进程内一级缓存实例。默认 5 分钟过期、10 分钟清理一次(与原 appg/skdg 缓存参数保持一致)。
var C = cache.New(5*time.Minute, 10*time.Minute)