优化MMAP相关功能

This commit is contained in:
GoEdgeLab
2024-04-04 08:28:14 +08:00
parent 4c30c28b4c
commit dcd8a0e020
12 changed files with 65 additions and 61 deletions

View File

@@ -89,21 +89,21 @@ func (this *MemoryList) Add(hash string, item *Item) error {
return nil
}
func (this *MemoryList) Exist(hash string) (bool, error) {
func (this *MemoryList) Exist(hash string) (bool, int64, error) {
this.locker.RLock()
defer this.locker.RUnlock()
prefix := this.prefix(hash)
itemMap, ok := this.itemMaps[prefix]
if !ok {
return false, nil
return false, -1, nil
}
item, ok := itemMap[hash]
if !ok {
return false, nil
return false, -1, nil
}
return !item.IsExpired(), nil
return !item.IsExpired(), -1, nil
}
// CleanPrefix 根据前缀进行清除