redis

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package redis author gmfan date 2023/3/1

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client() *redis.Client

func Del

func Del(ctx context.Context, keys ...string) (err error)

Del 删除 keys

func Get

func Get(ctx context.Context, key string, res any) (err error)

Get 获取 key 对应的 value,此方法会对 Redis 中的 value 进行反序列化 并将值保存到 res 中,所以 res 必须为指针

func InitRedis

func InitRedis(conf Conf) (err error)

InitRedis 初始化 Redis 客户端

func LoadEnvConf

func LoadEnvConf(c *Conf, must bool)

LoadEnvConf 加载环境比那辆中的 Redis 配置,must 设置为是否必须

func Set

func Set(ctx context.Context, key string, value any, expire int64) (err error)

Set 设置键值对,expire 单位为秒。此方法会对 value 进行序列化

Types

type Conf

type Conf struct {
	Host     string
	Pwd      string
	DB       int
	PoolSize int
}

Jump to

Keyboard shortcuts

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