redis

package
v0.0.0-...-360bc3d Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Overview

@Author Chen_dark @Date 2024/10/31 11:16:00 @Desc

Index

Constants

View Source
const (
	// 默认连接池超过 10 s 释放连接
	DefaultIdleTimeoutSeconds = 10
	// 默认最大激活连接数
	DefaultMaxActive = 100
	// 默认最大空闲连接数
	DefaultMaxIdle = 20
)

Variables

View Source
var ErrNoMsg = errors.New("no msg received")

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client Redis 客户端.

func NewClient

func NewClient(config Config, opts ...ClientOption) *Client

NewClient 新建Client并初始化

func NewClientWithPool

func NewClientWithPool(pool *redis.Pool, opts ...ClientOption) *Client

func (*Client) Del

func (c *Client) Del(ctx context.Context, key string) error

func (*Client) Eval

func (c *Client) Eval(ctx context.Context, src string, keyCount int, keysAndArgs []interface{}) (interface{}, error)

Eval 支持使用 lua 脚本.

func (*Client) Get

func (c *Client) Get(ctx context.Context, key string) (string, error)

func (*Client) GetConn

func (c *Client) GetConn(ctx context.Context) (redis.Conn, error)

func (*Client) Incr

func (c *Client) Incr(ctx context.Context, key string) (int64, error)

func (*Client) Set

func (c *Client) Set(ctx context.Context, key, value string) (int64, error)

func (*Client) SetNEX

func (c *Client) SetNEX(ctx context.Context, key, value string, expireSeconds int64) (int64, error)

func (*Client) SetNX

func (c *Client) SetNX(ctx context.Context, key, value string) (int64, error)

func (*Client) XACK

func (c *Client) XACK(ctx context.Context, topic, groupID, msgID string) error

func (*Client) XADD

func (c *Client) XADD(ctx context.Context, topic string, maxLen int, key, val string) (string, error)

func (*Client) XADDJson

func (c *Client) XADDJson(ctx context.Context, topic string, maxLen int, key, val string) (string, error)

func (*Client) XGroupCreate

func (c *Client) XGroupCreate(ctx context.Context, topic, group string) (string, error)

func (*Client) XReadGroup

func (c *Client) XReadGroup(ctx context.Context, groupID, consumerID, topic string, timeoutMiliSeconds int) ([]*MsgEntity, error)

func (*Client) XReadGroupPending

func (c *Client) XReadGroupPending(ctx context.Context, groupID, consumerID, topic string) ([]*MsgEntity, error)

type ClientOption

type ClientOption func(c *ClientOptions)

func WithIdleTimeoutSeconds

func WithIdleTimeoutSeconds(idleTimeoutSeconds int) ClientOption

func WithMaxActive

func WithMaxActive(maxActive int) ClientOption

func WithMaxIdle

func WithMaxIdle(maxIdle int) ClientOption

func WithWaitMode

func WithWaitMode() ClientOption

type ClientOptions

type ClientOptions struct {
	// contains filtered or unexported fields
}

type Config

type Config struct {
	Network  string `mapstructure:"network"`  // 网络类型 TCP
	Address  string `mapstructure:"address"`  // redis地址 ip:port
	Password string `mapstructure:"password"` // redis密码

}

type ConsumerConfig

type ConsumerConfig struct {
	RedisConfig Config
	GroupID     string //消费者组名称
	ConsumerID  string //消费者名称
	Topic       string
}

type MsgEntity

type MsgEntity struct {
	MsgID string
	Key   string
	Val   string
}

type ProducerConfig

type ProducerConfig struct {
	RedisConfig Config
	Topic       string `mapstructure:"topic"`
}

Jump to

Keyboard shortcuts

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