Documentation
¶
Index ¶
- Constants
- Variables
- func CheckAndGet(ctx context.Context, key string) (string, error)
- func CheckAndScan(ctx context.Context, dst any, key string) error
- func Del(ctx context.Context, keys ...string) error
- func Exists(ctx context.Context, key string) (bool, error)
- func Expire(ctx context.Context, key string, expiration time.Duration) error
- func Get(ctx context.Context, key string) (string, error)
- func GetAndScan(ctx context.Context, dst any, key string) error
- func HDel(ctx context.Context, key string, fields ...string) error
- func HGet(ctx context.Context, key, field string) (string, error)
- func HGetAndScan(ctx context.Context, dst any, key, field string) error
- func HKeys(ctx context.Context, key string) ([]string, error)
- func HKeysAndScan(ctx context.Context, key string, dst any) error
- func HLen(ctx context.Context, key string) (int64, error)
- func HMGet(ctx context.Context, key string, fields ...string) ([]any, error)
- func HMGetAndScan(ctx context.Context, dst any, key string, fields ...string) error
- func HSet(ctx context.Context, key string, values ...any) error
- func HVals(ctx context.Context, key string) ([]string, error)
- func HValsScan(ctx context.Context, dst any, key string) error
- func Init(cfg *Config) error
- func MGet(ctx context.Context, keys ...string) ([]interface{}, error)
- func MGetAndScan(ctx context.Context, dst any, keys ...string) error
- func Pop(ctx context.Context, key string) (string, error)
- func PopAndScan(ctx context.Context, dst any, key string) error
- func Push(ctx context.Context, key string, data ...any) error
- func RandomExpirationDuration() time.Duration
- func Rang(ctx context.Context, key string, limit int64) ([]string, error)
- func RangAndScan(ctx context.Context, dst any, key string, limit int64) error
- func Redis() redis.UniversalClient
- func Set(ctx context.Context, key string, data any, expiration time.Duration) error
- func SetNX(ctx context.Context, key string, data any, expiration time.Duration) error
- type Config
- type RedisConfig
Constants ¶
View Source
const ( // KeepTTL 保持原先的过期时间(TTL) KeepTTL = -1 // DefaultEmptySetNXDuration 默认空对象设置过期时效 DefaultEmptySetNXDuration = time.Second * 10 // DefaultExpirationDuration 默认缓存过期时效 DefaultExpirationDuration = time.Hour )
Variables ¶
Functions ¶
func CheckAndGet ¶
CheckAndGet 检测并获取数据
func CheckAndScan ¶
CheckAndScan 获取数据
func HGetAndScan ¶
HGetAndScan 获取Hash表指定字段的值
func HKeysAndScan ¶
HKeysAndScan 获取Hash表的所有键并扫描到dst中
func HMGetAndScan ¶
HMGetAndScan 获取Hash表指定字段的值并扫描进入到dst中
func MGetAndScan ¶
MGetAndScan 获取多个Keys的值并扫描进dst中
func PopAndScan ¶
PopAndScan 通过扫描方式取出列表内的第一个数据
func RandomExpirationDuration ¶
RandomExpirationDuration 以 DefaultExpirationDuration 为基础,返回一个 DefaultExpirationDuration ± 30m 内的时间长度
func RangAndScan ¶
RangAndScan 通过扫描方式获取列表内的范围内数据
func Redis ¶
func Redis() redis.UniversalClient
Types ¶
type Config ¶
type Config struct {
Redis *RedisConfig `json:"redis" yaml:"redis"`
}
Click to show internal directories.
Click to hide internal directories.