Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache interface {
// SetMaxMemory size : 1KB 100KB 1M 2MB 1GB
SetMaxMemory(size string) bool
Set(key string, val any, expire time.Duration) error
Get(key string, result any) error
Del(key string) bool
Exists(key string) bool
Clear() bool
// Keys 获取所有缓存中 key 的数量
Keys() int64
}
func DefaultCache ¶
func DefaultCache() Cache
type LocalCacheConf ¶
type RedisConf ¶
type RedisConf struct {
Addrs []string `mapstructure:"addrs"` // [127.0.0.1:6379, 127.0.0.1:7000]
Username string `mapstructure:"username"`
Password string `mapstructure:"password" mask:""`
DB uint8 `mapstructure:"db"` // 集群模式下无效
PoolSize int `mapstructure:"poolSize" yaml:"poolSize"`
ReadTimeout types.Duration `mapstructure:"readTimeout" yaml:"readTimeout" validate:"duration"` // 0.2s
WriteTimeout types.Duration `mapstructure:"writeTimeout" yaml:"writeTimeout" validate:"duration"` // 0.2s
}
type RedisManager ¶ added in v0.1.3
type RedisManager map[string]redis.UniversalClient
多数据源管理
func NewRedisManager ¶ added in v0.1.4
func NewRedisManager(appName string, cfgMap map[string]RedisConf) (RedisManager, error)
func (RedisManager) Default ¶ added in v0.1.3
func (m RedisManager) Default() redis.UniversalClient
func (RedisManager) Get ¶ added in v0.1.3
func (m RedisManager) Get(k string) redis.UniversalClient
Click to show internal directories.
Click to hide internal directories.