Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache interface {
Get(key string) (*CacheItem, error)
Set(key string, value *CacheItem, ttl int) error
Delete(key string) error
Close() error
}
Cache interface defines methods for cache operations 缓存接口定义了缓存操作的方法
type CacheManager ¶
type CacheManager struct {
// contains filtered or unexported fields
}
CacheManager manages cache operations and provides a unified interface 缓存管理器管理缓存操作并提供统一接口
func NewCacheManager ¶
func NewCacheManager(config config.Cache) (*CacheManager, error)
NewCacheManager creates a new cache manager based on configuration 根据配置创建新的缓存管理器
func (*CacheManager) Close ¶
func (m *CacheManager) Close() error
Close cleans up resources used by the cache 清理缓存使用的资源
func (*CacheManager) Delete ¶
func (m *CacheManager) Delete(key string) error
Delete removes a value from the cache by key 通过键从缓存中删除值
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache implements Cache interface using in-memory storage 内存缓存实现了使用内存存储的缓存接口
func NewMemoryCache ¶
func NewMemoryCache() *MemoryCache
NewMemoryCache creates a new memory cache instance 创建一个新的内存缓存实例
func (*MemoryCache) Close ¶
func (c *MemoryCache) Close() error
Close cleans up resources used by the cache 清理缓存使用的资源
func (*MemoryCache) Delete ¶
func (c *MemoryCache) Delete(key string) error
Delete removes a value from the cache by key 通过键从缓存中删除值
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
RedisCache implements Cache interface using Redis Redis缓存实现了使用Redis的缓存接口
func NewRedisCache ¶
func NewRedisCache(config config.Cache) (*RedisCache, error)
NewRedisCache creates a new Redis cache instance 创建一个新的Redis缓存实例
func (*RedisCache) Close ¶
func (c *RedisCache) Close() error
Close closes the Redis client connection 关闭Redis客户端连接
func (*RedisCache) Delete ¶
func (c *RedisCache) Delete(key string) error
Delete removes a value from Redis by key 通过键从Redis中删除值