Files
2026-08-05 10:28:44 +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
}