Files
slogan/server/common/cache.go
T
admin a6de9ebd12 Add 'server/' from commit 'e64421295fff83acbb6d6ab3d3b27f3ef8368f00'
git-subtree-dir: server
git-subtree-mainline: c4e617ada7
git-subtree-split: e64421295f
2026-08-04 15:02:35 +08:00

23 lines
404 B
Go

package common
import (
"context"
"sync"
"time"
"github.com/gogf/gf/v2/frame/g"
)
var (
cacheTTL time.Duration
cacheTTLOnce sync.Once
)
// CacheTTL returns the database query cache TTL from config
func CacheTTL() time.Duration {
cacheTTLOnce.Do(func() {
cacheTTL = time.Duration(g.Cfg().MustGet(context.Background(), "database.cache.ttl", 60).Int()) * time.Second
})
return cacheTTL
}