diff --git a/lib/core/cache/lcoal.go b/lib/core/cache/lcoal.go index 62f776a4..06b5628f 100644 --- a/lib/core/cache/lcoal.go +++ b/lib/core/cache/lcoal.go @@ -1,6 +1,7 @@ package cache import ( + "strings" "time" "github.com/patrickmn/go-cache" @@ -24,6 +25,17 @@ func DeleteLocal(key string) { cNoExpiration.Delete(key) } +// 获取指定前缀的所有键 +func GetLocalKeys(prefix string) []string { + var keys []string + for key := range cNoExpiration.Items() { + if strings.HasPrefix(key, prefix) { + keys = append(keys, key) + } + } + return keys +} + // 创建一个全局的过期缓存对象 var cTTL = cache.New(6*time.Hour, 12*time.Hour)