优化代码:使用fasttime取代以往的utils.UnixTime

This commit is contained in:
GoEdgeLab
2023-04-08 12:47:04 +08:00
parent 511e0d409f
commit f3da37046a
22 changed files with 208 additions and 137 deletions

View File

@@ -1,8 +1,8 @@
package ttlcache
import (
"github.com/TeaOSLab/EdgeNode/internal/utils"
"github.com/TeaOSLab/EdgeNode/internal/utils/expires"
"github.com/TeaOSLab/EdgeNode/internal/utils/fasttime"
"github.com/iwind/TeaGo/types"
"sync"
"time"
@@ -75,7 +75,7 @@ func (this *Piece) Delete(key uint64) {
func (this *Piece) Read(key uint64) (item *Item) {
this.locker.RLock()
item = this.m[key]
if item != nil && item.expiredAt < utils.UnixTime() {
if item != nil && item.expiredAt < fasttime.Now().Unix() {
item = nil
}
this.locker.RUnlock()