This commit is contained in:
2025-06-13 17:23:16 +08:00
parent 3150ba80bc
commit 1b72f51e4a
55 changed files with 3894 additions and 310 deletions

View File

@@ -8,14 +8,14 @@ import (
"time"
"management/internal/erpserver/model/view"
"management/internal/pkg/redis"
"management/internal/pkg/cache"
)
func GetCacheExpire() time.Duration {
return time.Hour*6 + time.Duration(rand.Intn(600))*time.Second // 6小时±10分钟
}
func GetOrSetCache(ctx context.Context, redis redis.Cache, key string, expire time.Duration, getData func() (any, error), result any) error {
func GetOrSetCache(ctx context.Context, redis cache.Cache, key string, expire time.Duration, getData func() (any, error), result any) error {
if data, err := redis.GetBytes(ctx, key); err == nil {
return json.Unmarshal(data, result)
}