Documentation
¶
Index ¶
- Variables
- func IsCacheMiss(err error) bool
- type Config
- type Manager
- func (m *Manager) Close() error
- func (m *Manager) Delete(ctx context.Context, keys ...string) error
- func (m *Manager) Exists(ctx context.Context, keys ...string) (int64, error)
- func (m *Manager) Expire(ctx context.Context, key string, ttl time.Duration) error
- func (m *Manager) Get(ctx context.Context, key string) (string, error)
- func (m *Manager) GetJSON(ctx context.Context, key string, dest any) error
- func (m *Manager) GetStats(ctx context.Context) (*Stats, error)
- func (m *Manager) Ping(ctx context.Context) error
- func (m *Manager) Set(ctx context.Context, key string, value string, ttl time.Duration) error
- func (m *Manager) SetJSON(ctx context.Context, key string, value any, ttl time.Duration) error
- type Stats
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCacheMiss = errors.New("cache miss")
ErrCacheMiss 缓存未命中错误
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Redis 地址
Addr string `yaml:"addr" json:"addr"`
// 密码
Password string `yaml:"password" json:"password"`
// 数据库编号
DB int `yaml:"db" json:"db"`
// 默认过期时间
DefaultTTL time.Duration `yaml:"default_ttl" json:"default_ttl"`
// 最大重试次数
MaxRetries int `yaml:"max_retries" json:"max_retries"`
// 连接池大小
PoolSize int `yaml:"pool_size" json:"pool_size"`
// 最小空闲连接数
MinIdleConns int `yaml:"min_idle_conns" json:"min_idle_conns"`
// 是否启用 TLS
TLSEnabled bool `yaml:"tls_enabled" json:"tls_enabled"`
// 健康检查间隔
HealthCheckInterval time.Duration `yaml:"health_check_interval" json:"health_check_interval"`
}
Config 缓存配置
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager 缓存管理器
func NewManager ¶
NewManager 创建缓存管理器
Click to show internal directories.
Click to hide internal directories.