redis

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 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) Keys

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

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

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