优化文件句柄缓存容量判断

This commit is contained in:
刘祥超
2023-10-17 09:59:04 +08:00
parent 2acf890b8e
commit 822e967874

View File

@@ -93,7 +93,7 @@ func (this *OpenFileCache) Put(filename string, file *OpenFile) {
defer this.locker.Unlock() defer this.locker.Unlock()
// 如果超过当前容量,则关闭最早的 // 如果超过当前容量,则关闭最早的
if this.count >= this.maxCount || this.usedSize >= this.capacitySize { if this.count >= this.maxCount || this.usedSize+file.size >= this.capacitySize {
this.consumeHead() this.consumeHead()
return return
} }