redis

package
v0.0.0-...-431a833 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	Client() *redis.ClusterClient
	Set(ctx context.Context, key, value string, expiration time.Duration) error
	Get(ctx context.Context, key string) (string, error)
	Existed(ctx context.Context, keys ...string) bool
	Keys(ctx context.Context, pattern string) ([]string, error)
	Del(ctx context.Context, keys ...string) error
	Expire(ctx context.Context, key string, duration time.Duration) error
}

Interface Redis 集群操作接口

func NewRedis

func NewRedis(config Options) Interface

NewRedis 根据配置实例化一个Redis 接口

type Options

type Options struct {
	Address  []string `json:"address,omitempty" yaml:"address,omitempty" xml:"address,omitempty"`
	Username string   `json:"username,omitempty" yaml:"username,omitempty" xml:"username,omitempty"`
	Password string   `json:"password,omitempty" yaml:"password,omitempty" xml:"password,omitempty"`
	DB       int32    `json:"db,omitempty" yaml:"db,omitempty" xml:"db,omitempty"`
}

func NewRedisOptions

func NewRedisOptions() *Options

NewRedisOptions 实例化Redis Options

func (*Options) Client

func (r *Options) Client() *redis.ClusterClient

Client 创建并返回一个新的Redis集群客户端。

func (*Options) Del

func (r *Options) Del(ctx context.Context, keys ...string) error

Del 删除key

func (*Options) Existed

func (r *Options) Existed(ctx context.Context, keys ...string) bool

Existed 判断Keys是否存在

func (*Options) Expire

func (r *Options) Expire(ctx context.Context, key string, duration time.Duration) error

Expire 设置key过期

func (*Options) Get

func (r *Options) Get(ctx context.Context, key string) (string, error)

Get 查询数据

func (*Options) Keys

func (r *Options) Keys(ctx context.Context, pattern string) ([]string, error)

Keys 查询批量keys redis接口实现

func (*Options) Set

func (r *Options) Set(ctx context.Context, key, value string, expiration time.Duration) error

Set 写入数据

Jump to

Keyboard shortcuts

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