package single import ( "gitee.com/timedb/wheatCache/pkg/event" "gitee.com/timedb/wheatCache/pkg/lru" "gitee.com/timedb/wheatCache/storage/dao" "github.com/spf13/viper" "time" ) type serverSingle struct { middleProduce event.ProduceInterface lruProduce event.ProduceInterface timeOut time.Duration lruCache *lru.SingleCache dao *dao.Dao } func NewServer() *serverSingle { oneSingleServer.Do(func() { timeOut := viper.GetInt("storage.timeOut") if timeOut == 0 { timeOut = timeOutDefault } lruCache := lru.NewLRUCache() ser := &serverSingle{ lruCache: lruCache, lruProduce: event.NewProduce(lruCache.GetDriver()), timeOut: time.Duration(timeOut), dao: dao.NewDao(lruCache), } sysSingleServer = ser }) return sysSingleServer }