mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-01-07 08:15:49 +08:00
[缓存]实现按照目录刷新缓存
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package caches
|
||||
|
||||
import "sync"
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// 缓存列表管理
|
||||
type List struct {
|
||||
@@ -43,6 +46,20 @@ func (this *List) Exist(hash string) bool {
|
||||
return !item.IsExpired()
|
||||
}
|
||||
|
||||
// 根据前缀进行查找
|
||||
func (this *List) FindKeysWithPrefix(prefix string) (keys []string) {
|
||||
this.locker.RLock()
|
||||
defer this.locker.RUnlock()
|
||||
|
||||
// TODO 需要优化性能,支持千万级数据低于1s的处理速度
|
||||
for _, item := range this.m {
|
||||
if strings.HasPrefix(item.Key, prefix) {
|
||||
keys = append(keys, item.Key)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *List) Remove(hash string) {
|
||||
this.locker.Lock()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user