From 2ab01037d8855a5833426697f2a5f4681db23366 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Tue, 5 Sep 2023 19:04:08 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E8=8E=B7=E5=8F=96=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E5=89=8D=E7=BC=80=E7=9A=84=E6=89=80=E6=9C=89=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core/cache/lcoal.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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)