mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-11 05:00:25 +08:00
优化缓存相关代码
This commit is contained in:
@@ -31,6 +31,7 @@ func (this *OpenFilePool) Filename() string {
|
||||
func (this *OpenFilePool) Get() (*OpenFile, bool) {
|
||||
select {
|
||||
case file := <-this.c:
|
||||
if file != nil {
|
||||
err := file.SeekStart()
|
||||
if err != nil {
|
||||
_ = file.Close()
|
||||
@@ -39,6 +40,8 @@ func (this *OpenFilePool) Get() (*OpenFile, bool) {
|
||||
file.version = this.version
|
||||
|
||||
return file, true
|
||||
}
|
||||
return nil, false
|
||||
default:
|
||||
return nil, false
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user