redis

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RC = RedisClient{} // 全局 Redis 客户端实例
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Addrs     []string
	Password  string
	DB        int
	IsCluster bool
}

type RedisClient

type RedisClient struct {
	// contains filtered or unexported fields
}

func NewRedis

func NewRedis(cfg Config) (*RedisClient, error)

NewRedis 创建 Redis 客户端

func (*RedisClient) Del

func (r *RedisClient) Del(keys ...string) error

Del 删除键

func (*RedisClient) Exists

func (r *RedisClient) Exists(key string) (bool, error)

Exists 判断键是否存在

func (*RedisClient) Get

func (r *RedisClient) Get(key string) (string, error)

Get 获取值

func (*RedisClient) GetMap

func (r *RedisClient) GetMap(key string) (map[string]interface{}, error)

Get 获取MAP值

func (*RedisClient) GetMaps

func (r *RedisClient) GetMaps(key string) ([]map[string]interface{}, error)

Get 获取MAP数组值

func (*RedisClient) HDel

func (r *RedisClient) HDel(key string, fields ...string) error

HDel 删除哈希字段

func (*RedisClient) HGet

func (r *RedisClient) HGet(key, field string) (string, error)

HGet 获取哈希字段

func (*RedisClient) HSet

func (r *RedisClient) HSet(key string, values ...interface{}) error

HSet 设置哈希字段

func (*RedisClient) HSetWithExpire added in v0.0.5

func (r *RedisClient) HSetWithExpire(key string, ttl time.Duration, values ...interface{}) error

func (*RedisClient) Keys

func (r *RedisClient) Keys(pattern string) ([]string, error)

Keys 获取匹配的 key 列表(仅支持单节点)

func (*RedisClient) LIndex added in v0.0.5

func (r *RedisClient) LIndex(key string, index int64) (string, error)

获取指定下标的数据

func (*RedisClient) LLen added in v0.0.5

func (r *RedisClient) LLen(key string) (int64, error)

查询 List 长度

func (*RedisClient) LPop added in v0.0.5

func (r *RedisClient) LPop(key string) (string, error)

弹出数据(从左边)

func (*RedisClient) LPush added in v0.0.5

func (r *RedisClient) LPush(key string, values ...interface{}) error

插入数据(左插入,最新数据在最前)

func (*RedisClient) LRange added in v0.0.5

func (r *RedisClient) LRange(key string, start, stop int64) ([]string, error)

获取指定区间的数据 start=0, stop=-1 表示获取全部

func (*RedisClient) RPop added in v0.0.5

func (r *RedisClient) RPop(key string) (string, error)

弹出数据(从右边)

func (*RedisClient) RPush added in v0.0.5

func (r *RedisClient) RPush(key string, values ...interface{}) error

插入数据(右插入,最新数据在最后)

func (*RedisClient) RPushWithExpire added in v0.0.5

func (r *RedisClient) RPushWithExpire(key string, ttl time.Duration, values ...interface{}) error

插入并设置过期时间

func (*RedisClient) Set

func (r *RedisClient) Set(key string, value interface{}, expiration time.Duration) error

Set 设置键值

Jump to

Keyboard shortcuts

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