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 }