redis

package
v0.0.0-...-04efeb6 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RedisEnabled bool

RedisConfig 存储配置信息

Functions

func Decrease

func Decrease(key string, value int64) error

RedisDecrease Redis 键值递减

func Del

func Del(key string) error

RedisDel 删除 Redis 键

func Get

func Get(key string) (string, error)

RedisGet 获取 Redis 键的值

func InitRedisClient

func InitRedisClient(cfg *config.RedisConfig) error

InitRedisClient 初始化 Redis 客户端

func Set

func Set(key string, value string, expiration time.Duration) error

RedisSet 设置 Redis 键值对

Types

type RedisClient

type RedisClient interface {
	Ping(ctx context.Context) *redis.StatusCmd
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	Get(ctx context.Context, key string) *redis.StringCmd
	Del(ctx context.Context, keys ...string) *redis.IntCmd
	DecrBy(ctx context.Context, key string, decrement int64) *redis.IntCmd
	LPush(ctx context.Context, key string, values ...interface{}) *redis.IntCmd
	LTrim(ctx context.Context, key string, start, stop int64) *redis.StatusCmd
	Expire(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd
	LLen(ctx context.Context, key string) *redis.IntCmd
	LIndex(ctx context.Context, key string, index int64) *redis.StringCmd
}

RedisClient 是 Redis 客户端接口,方便后期扩展和替换

var RDB RedisClient

Jump to

Keyboard shortcuts

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