Documentation
¶
Index ¶
- type Redis
- func (r *Redis) CacheWithString(key string, output interface{}, expire time.Duration, ...) error
- func (r *Redis) HGetAll(key string) (result []interface{})
- func (r *Redis) HMDel(key string, fields ...string) error
- func (r *Redis) HMSet(key string, data map[string]interface{}) error
- func (r *Redis) NewRedis(rdc *types.RedisCollector, cli *types.RedisClient, f func() *redis.Options) (*redis.Client, error)
- func (r *Redis) NoDataExpiration() time.Duration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Redis ¶
func (*Redis) CacheWithString ¶
func (r *Redis) CacheWithString(key string, output interface{}, expire time.Duration, fn func() (interface{}, bool)) error
从String类型的缓存中读取数据,如没则重新调用指定方法重新从数据库中读取并写入缓存
func (*Redis) NewRedis ¶
func (r *Redis) NewRedis(rdc *types.RedisCollector, cli *types.RedisClient, f func() *redis.Options) (*redis.Client, error)
func (*Redis) NoDataExpiration ¶
数据不存在情况下,为防止缓存雪崩,随机返回一个30到60秒的有效时间
Click to show internal directories.
Click to hide internal directories.