优化后台高频查询性能

This commit is contained in:
yml2213
2026-08-29 00:16:16 +08:00
parent c87883cc65
commit c156c478d8
17 changed files with 684 additions and 175 deletions
@@ -1,13 +1,19 @@
package adminfinance
import (
"github.com/redis/go-redis/v9"
"gorm.io/gorm"
)
type Repository struct {
db *gorm.DB
db *gorm.DB
redis *redis.Client
}
func NewRepository(db *gorm.DB) *Repository {
return &Repository{db: db}
func NewRepository(db *gorm.DB, redisClient ...*redis.Client) *Repository {
repo := &Repository{db: db}
if len(redisClient) > 0 {
repo.redis = redisClient[0]
}
return repo
}