2020-05-22 20:00:33 +02:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
|
2020-05-30 01:41:47 +02:00
|
|
|
"github.com/allegro/bigcache"
|
2020-05-22 20:00:33 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
var onceCache sync.Once
|
|
|
|
|
|
|
|
func initCache() {
|
2020-05-30 01:41:47 +02:00
|
|
|
var err error
|
|
|
|
|
|
|
|
services.Cache, err = bigcache.NewBigCache(bigcache.DefaultConfig(time.Hour))
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("")
|
|
|
|
}
|
2020-05-22 20:00:33 +02:00
|
|
|
}
|
|
|
|
|
2020-05-30 01:41:47 +02:00
|
|
|
func Cache() *bigcache.BigCache {
|
2020-05-22 20:00:33 +02:00
|
|
|
onceCache.Do(initCache)
|
|
|
|
|
|
|
|
return services.Cache
|
|
|
|
}
|