redis

package
v0.0.0-...-8e20547 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Redis

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Redis

type Redis struct {
	Host     string `mapstructure:"Host"`     // 连接地址
	Port     int32  `mapstructure:"Port"`     // 连接地址
	Password string `mapstructure:"Password"` // 密码
	Index    int32  `mapstructure:"Index"`    // 数据库
	PoolSize int32  `mapstructure:"PoolSize"` // 连接池大小
	Timeout  int32  `mapstructure:"Timeout"`  // 超时时间
	KeyNil   error  // 定义键不存在错误,避免业务中导入redis包
	*redis.Client
}

Redis配置

func (*Redis) Connect

func (r *Redis) Connect() (rdb *Redis, ctx context.Context, cancel context.CancelFunc)

实例化连接

func (*Redis) IncrX

func (r *Redis) IncrX(ctx context.Context, key string, expire uint32) (val uint32, err error)

扩展Incr方法,支持过期时间

func (*Redis) StreamGroupConsumerCreate

func (r *Redis) StreamGroupConsumerCreate(streamKey string, groupName string, consumerName string) (err error)

组消费者创建

func (*Redis) StreamGroupCreate

func (r *Redis) StreamGroupCreate(streamKey string, groupName string, beginMsgId string) (err error)

消费者组创建

func (*Redis) StreamMessageAdd

func (r *Redis) StreamMessageAdd(streamKey string, maxLen int64, values string) (msgId string, err error)

消息添加

func (*Redis) StreamMessageByGroupConsumer

func (r *Redis) StreamMessageByGroupConsumer(streamKey string, groupName string, consumerName string, count int64, block int64, noAck bool) (messages map[string]string, err error)

组内消息分配操作,组内每个消费者消费多少消息

func (*Redis) StreamXAck

func (r *Redis) StreamXAck(streamKey string, groupName string, vecMsgId []string) (err error)

消息已消费ACK确认

Jump to

Keyboard shortcuts

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