Add 'server/' from commit 'e64421295fff83acbb6d6ab3d3b27f3ef8368f00'
git-subtree-dir: server git-subtree-mainline:c4e617ada7git-subtree-split:e64421295f
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user