git-subtree-dir: server git-subtree-mainline:c4e617ada7git-subtree-split:e64421295f
23 lines
404 B
Go
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
|
|
}
|