redis

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2022 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Redis

type Redis struct {
	Client func() *goredis.Client
}

func (*Redis) CacheWithString

func (r *Redis) CacheWithString(key string, output interface{}, expiration time.Duration, fn func() (interface{}, bool)) error

从String类型的缓存中读取数据,如没则重新调用指定方法重新从数据库中读取并写入缓存

func (*Redis) DeleteCache

func (r *Redis) DeleteCache(key ...string) (int64, error)

根据key删除对应缓存

func (*Redis) HGetAll

func (r *Redis) HGetAll(key string) (result []interface{})

func (*Redis) HMDelete

func (r *Redis) HMDelete(key string, fields ...string) error

func (*Redis) HMSet

func (r *Redis) HMSet(key string, data map[string]interface{}) error

func (*Redis) NewRedis

func (r *Redis) NewRedis(rdc *types.RedisCollector, client *types.RedisClient) (*goredis.Client, error)

func (*Redis) NoDataExpiration

func (r *Redis) NoDataExpiration() time.Duration

数据不存在情况下,为防止缓存雪崩,随机返回一个30到60秒的有效时间

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL