优化后台高频查询性能
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user