redis

package
v0.0.0-...-388d6c9 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package redis implements a Redis client.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConsumerGroupExists is returned when the consumer group already exists
	ErrConsumerGroupExists = errors.New("BUSYGROUP Consumer Group name already exists")
)

Functions

This section is empty.

Types

type Client

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

Client Redis client wrapper

func New

func New(c *configs.RedisConfig) *Client

New create a new redis client

func NewMockRdb

func NewMockRdb() *Client

NewMockRdb get Redis mock client

func (*Client) Close

func (c *Client) Close() error

Close redis client

func (*Client) Del

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

Del executes the Redis Del 命令

func (*Client) Get

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

Get executes the Redis GET command it returns the value of key. If the key does not exist the special value nil is returned.

func (*Client) GetClient

func (c *Client) GetClient() *redis.Client

GetClient get redis client

func (*Client) HGet

func (c *Client) HGet(ctx context.Context, key, field string) ([]byte, error)

HGet executes the Redis HGet command

func (*Client) Set

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

Set executes the Redis SET command, expireTime time unit is seconds If expireTime is 0, it means not to set the expiration time

func (*Client) StreamSend

func (c *Client) StreamSend(ctx context.Context, streamName string, msg []byte) error

StreamSend send message to stream

func (*Client) XAck

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

XAck acknowledges messages

func (*Client) XGroupConsume

func (c *Client) XGroupConsume(ctx context.Context, topic, group, consumerName, id string,
	batchSize int) ([]redis.XMessage, error)

XGroupConsume consumes messages from a stream

func (*Client) XGroupCreate

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

XGroupCreate creates a new consumer group start argument is the ID of the first message to consume start can be specified as ID or $, where $ means from the last message

func (*Client) XGroupDelConsumer

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

XGroupDelConsumer delete consumer from consumer group

func (*Client) ZAddNX

func (c *Client) ZAddNX(ctx context.Context, key string, members ...redis.Z) error

ZAddNX executes the Redis ZAddNX command If the member already exists, the score is updated and the element reinserted at the right position to ensure the correct ordering.

func (*Client) ZRangeByScore

func (c *Client) ZRangeByScore(ctx context.Context, key string, opt *redis.ZRangeBy) ([]redis.Z, error)

ZRangeByScore executes the Redis ZRangeByScore command

func (*Client) ZRem

func (c *Client) ZRem(ctx context.Context, key string, members ...any) error

ZRem executes the Redis ZRem command

Jump to

Keyboard shortcuts

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