chore: initial commit

This commit is contained in:
2026-07-22 17:50:33 +08:00
parent 82936a8987
commit ee9f50b859
107 changed files with 8346 additions and 0 deletions

31
internal/pkg/cache/cache.go vendored Normal file
View File

@@ -0,0 +1,31 @@
package cache
import (
"server/internal/db/sqlc"
"github.com/maypok86/otter/v2"
)
type Caches struct {
SysUserApisCache *otter.Cache[int32, []db.GetSysUserApisRow]
}
func NewCaches() *Caches {
sysUserApisCache := otter.Must(&otter.Options[int32, []db.GetSysUserApisRow]{
MaximumSize: 1_000,
})
return &Caches{
SysUserApisCache: sysUserApisCache,
}
}
// ClearSysUserCache 清理单个用户缓存
func (c *Caches) ClearSysUserCache(userID int32) {
c.SysUserApisCache.Invalidate(userID)
}
// ClearAllSysUserCache 清理所有用户缓存
func (c *Caches) ClearAllSysUserCache() {
c.SysUserApisCache.InvalidateAll()
}