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)