redis_go

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(addr string, options ...Option)

Connect 连接redis

func DelEx

func DelEx(ctx context.Context, key string) (err error)

func Get

func Get[T RedisValueTypes](ctx context.Context, key string) (val T, isNotExist bool, err error)

func GetKeyEventExpired

func GetKeyEventExpired(db int) string

GetKeyEventExpired 需要修改redis.conf配置项,启用notify-keyspace-events = "EX"

func HashDel

func HashDel(ctx context.Context, key string, val string) (err error)

func HashGetAll

func HashGetAll(ctx context.Context, key string) (result map[string]string, isNotExist bool, err error)

func HashGetString

func HashGetString(ctx context.Context, key, field string) (result string, isNotExist bool, err error)

func HashSet

func HashSet(ctx context.Context, key string, val map[string]any, expiration time.Duration) (err error)

func HashUpdate

func HashUpdate(ctx context.Context, key string, val ...any) (err error)

func SetEx

func SetEx(ctx context.Context, key string, val any, exp time.Duration) (err error)

func Subscribe

func Subscribe(ctx context.Context, key string) (subscribe *redis.PubSub)

Types

type Option

type Option func(*Options)

func WithDB

func WithDB(db int) Option

WithDB 设置数据库

func WithPassword

func WithPassword(pwd string) Option

WithPassword 设置密码

func WithUsername

func WithUsername(user string) Option

WithUsername 设置用户名

type Options

type Options struct {
	Username string
	Password string
	DB       int
}

type RedisValueTypes

type RedisValueTypes interface {
	int | int64 | string | bool | []byte
}

Jump to

Keyboard shortcuts

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