feat: upgrade cache

This commit is contained in:
zhangdeman committed 2025-10-18 11:31:47 +08:00
1 parent eda887e8ff
commit 9f21048ac0
5 files changed
+14 -44

No files matched your search

+4 -12
View File
@@ -12,28 +12,20 @@ import (
)
// ResultParseFunc 结解析方法
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 11:18 2024/6/21
type ResultParseFunc func(res string) error
type ResultParseFunc func(res any) error
// ICache 缓存的接口约束
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 12:09 2024/6/21
type ICache interface {
// Exist 缓存是否存在
Exist(ctx context.Context, cacheInstanceFlag string, key string) (bool, error)
// TTL key还有多长时间过期
TTL(ctx context.Context, cacheInstanceFlag string, key string) (int64, error)
// Set 设置缓存
Set(ctx context.Context, cacheInstanceFlag string, key string, value string, ttl int64) error
Set(ctx context.Context, cacheInstanceFlag string, key string, value any, ttl int64) error
// Get 读取原始缓存数据
Get(ctx context.Context, cacheInstanceFlag string, key string) (string, error)
Get(ctx context.Context, cacheInstanceFlag string, key string) (any, error)
// GetWithParse 获取结果并解析
GetWithParse(ctx context.Context, cacheInstanceFlag string, key string, parseFunc ResultParseFunc) (string, error)
GetWithParse(ctx context.Context, cacheInstanceFlag string, key string, parseFunc ResultParseFunc) (any, error)
// Delete 删除缓存
Delete(ctx context.Context, cacheInstanceFlag string, key string) error
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.