// Package cache ... // // Description : cache ... // // Author : go_developer@163.com<白茶清欢> // // Date : 2023-03-21 12:09 package cache import ( "context" ) // ResultParseFunc 结解析方法 // // Author : go_developer@163.com<白茶清欢> // // Date : 11:18 2024/6/21 type ResultParseFunc func(res string) 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) // Set 设置缓存 Set(ctx context.Context, cacheInstanceFlag string, key string, value string, ttl int64) error // Get 读取原始缓存数据 Get(ctx context.Context, cacheInstanceFlag string, key string) (string, error) // GetWithParse 获取结果并解析 GetWithParse(ctx context.Context, cacheInstanceFlag string, key string, parseFunc ResultParseFunc) (string, error) // Delete 删除缓存 Delete(ctx context.Context, cacheInstanceFlag string, key string) error }