redis

package
v0.0.0-...-42499df Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package redis 工具包

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectRedis

func ConnectRedis(address string, username string, password string, db int)

ConnectRedis 连接 redis 数据库,设置全局的 Redis 对象

Types

type RedisClient

type RedisClient struct {
	Client  *redis.Client
	Context context.Context
}

RedisClient Redis 服务

var Redis *RedisClient

Redis 全局 Redis,使用 db 1

func NewClient

func NewClient(conf *conf.Redis) *RedisClient

NewClient 创建一个新的 redis 连接

func (RedisClient) Decrement

func (rds RedisClient) Decrement(parameters ...interface{}) bool

Decrement 当参数只有 1 个时,为 key,其值减去 1。 当参数有 2 个时,第一个参数为 key ,第二个参数为要减去的值 int64 类型。

func (RedisClient) Del

func (rds RedisClient) Del(keys ...string) bool

Del 删除存储在 redis 里的数据,支持多个 key 传参

func (RedisClient) FlushDB

func (rds RedisClient) FlushDB() bool

FlushDB 清空当前 redis db 里的所有数据

func (RedisClient) Get

func (rds RedisClient) Get(key string, model interface{}) error

Get 获取 key 对应的 value

func (RedisClient) GetAwaitSendKey

func (rds RedisClient) GetAwaitSendKey(iccid, slaveId string, markType string, groupId int) string

func (RedisClient) GetDeviceKey

func (rds RedisClient) GetDeviceKey(iccid string) string

func (RedisClient) GetPropertyKey

func (rds RedisClient) GetPropertyKey() string

func (RedisClient) GetSlaveKey

func (rds RedisClient) GetSlaveKey(iccid string) string

func (RedisClient) HGet

func (rds RedisClient) HGet(key, field string, model interface{}) error

func (RedisClient) HGetAll

func (rds RedisClient) HGetAll(key string, model interface{}) error

func (RedisClient) HMSet

func (rds RedisClient) HMSet(key string, model interface{})

func (RedisClient) HSet

func (rds RedisClient) HSet(key, field string, model interface{})

func (RedisClient) Has

func (rds RedisClient) Has(key string) bool

Has 判断一个 key 是否存在,内部错误和 redis.Nil 都返回 false

func (RedisClient) Increment

func (rds RedisClient) Increment(parameters ...interface{}) bool

Increment 当参数只有 1 个时,为 key,其值增加 1。 当参数有 2 个时,第一个参数为 key ,第二个参数为要增加的值 int64 类型。

func (RedisClient) Lpop

func (rds RedisClient) Lpop(key string) string

Lpop Loop 出列

func (RedisClient) Ping

func (rds RedisClient) Ping() error

Ping 用以测试 redis 连接是否正常

func (RedisClient) Rpush

func (rds RedisClient) Rpush(key string, value interface{}) bool

Rpush 写入队列

func (RedisClient) Set

func (rds RedisClient) Set(key string, value interface{}, expiration time.Duration) bool

Set 存储 key 对应的 value,且设置 expiration 过期时间

Jump to

Keyboard shortcuts

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