From b36d70587d4246adcc3c9fefdfe11dffc39f740f Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Mon, 5 Dec 2022 10:46:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=93=E5=AD=98=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/caches/open_file_pool.go | 17 ++++++++++------- internal/caches/storage_file.go | 9 --------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/internal/caches/open_file_pool.go b/internal/caches/open_file_pool.go index 582f92b..0ac2505 100644 --- a/internal/caches/open_file_pool.go +++ b/internal/caches/open_file_pool.go @@ -31,14 +31,17 @@ func (this *OpenFilePool) Filename() string { func (this *OpenFilePool) Get() (*OpenFile, bool) { select { case file := <-this.c: - err := file.SeekStart() - if err != nil { - _ = file.Close() - return nil, true - } - file.version = this.version + if file != nil { + err := file.SeekStart() + if err != nil { + _ = file.Close() + return nil, true + } + file.version = this.version - return file, true + return file, true + } + return nil, false default: return nil, false } diff --git a/internal/caches/storage_file.go b/internal/caches/storage_file.go index f2de7d5..539872a 100644 --- a/internal/caches/storage_file.go +++ b/internal/caches/storage_file.go @@ -710,9 +710,6 @@ func (this *FileStorage) Delete(key string) error { return nil } - this.locker.Lock() - defer this.locker.Unlock() - // 先尝试内存缓存 this.runMemoryStorageSafety(func(memoryStorage *MemoryStorage) { _ = memoryStorage.Delete(key) @@ -733,9 +730,6 @@ func (this *FileStorage) Delete(key string) error { // Stat 统计 func (this *FileStorage) Stat() (*Stat, error) { - this.locker.RLock() - defer this.locker.RUnlock() - return this.list.Stat(func(hash string) bool { return true }) @@ -834,9 +828,6 @@ func (this *FileStorage) Purge(keys []string, urlType string) error { return nil } - this.locker.Lock() - defer this.locker.Unlock() - // 先尝试内存缓存 this.runMemoryStorageSafety(func(memoryStorage *MemoryStorage) { _ = memoryStorage.Purge(keys, urlType)