Documentation ¶
Index ¶
- type Redis
- func (r *Redis) CacheWithString(key string, output interface{}, expiration time.Duration, ...) error
- func (r *Redis) DeleteCache(key ...string) (int64, error)
- func (r *Redis) HGetAll(key string) (result []interface{})
- func (r *Redis) HMDelete(key string, fields ...string) error
- func (r *Redis) HMSet(key string, data map[string]interface{}) error
- func (r *Redis) NewRedis(rdc *types.RedisCollector, client *types.RedisClient) (*goredis.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{}, expiration time.Duration, fn func() (interface{}, bool)) error
从String类型的缓存中读取数据,如没则重新调用指定方法重新从数据库中读取并写入缓存
func (*Redis) NewRedis ¶
func (r *Redis) NewRedis(rdc *types.RedisCollector, client *types.RedisClient) (*goredis.Client, error)
func (*Redis) NoDataExpiration ¶
数据不存在情况下,为防止缓存雪崩,随机返回一个30到60秒的有效时间
Click to show internal directories.
Click to hide internal directories.