redis

package
v1.0.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const GlobalEvent = "global_event"

Variables

View Source
var Client = New(ctx, Options{
	Addr:     "127.0.0.0:6379",
	Password: "",
	DB:       0,
})

Functions

This section is empty.

Types

type Options

type Options struct {
	Addr     string
	Password string
	DB       int
}

type Redis

type Redis struct {
	// 订阅服务器实例
	Point *redis.Client
	// 订阅列表
	PbFns sync.Map
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, options Options) *Redis

func (*Redis) CreateQueue

func (r *Redis) CreateQueue(ctx context.Context, k string) error

func (*Redis) Destroy

func (r *Redis) Destroy(ctx context.Context, key string) error

func (*Redis) Do

func (r *Redis) Do(ctx context.Context, key string, time int) error

func (*Redis) Expire

func (r *Redis) Expire(ctx context.Context, k string, expire time.Duration) error

func (*Redis) Get

func (r *Redis) Get(ctx context.Context, k string) (string, error)

func (*Redis) GetOriginPoint

func (r *Redis) GetOriginPoint() *redis.Client

GetOriginPoint 获取原始redis实例

func (*Redis) HDel

func (r *Redis) HDel(ctx context.Context, k string, field string) error

func (*Redis) HGet

func (r *Redis) HGet(ctx context.Context, k, field string) (string, error)

func (*Redis) HGetAllByScan

func (r *Redis) HGetAllByScan(ctx context.Context, k string) (result map[string]string, err error)

func (*Redis) HSet

func (r *Redis) HSet(ctx context.Context, k string, fields ...string) error

func (*Redis) Incr

func (r *Redis) Incr(ctx context.Context, key string) (int64, error)

func (*Redis) Pop

func (r *Redis) Pop(ctx context.Context, k string) <-chan string

func (*Redis) Push

func (r *Redis) Push(ctx context.Context, k, field string) error

func (*Redis) Scan

func (r *Redis) Scan(ctx context.Context, cursor uint64, match string, count int64) (keys []string, newCursor uint64, err error)

func (*Redis) Set

func (r *Redis) Set(ctx context.Context, k, v string, expires time.Duration) error

func (*Redis) SetNx

func (r *Redis) SetNx(ctx context.Context, key, val string, expire time.Duration) (bool, error)

func (*Redis) Subscribe

func (r *Redis) Subscribe(k string, pb func(message string))

Subscribe 订阅指定键过期时间,需要redis开启键空间消息通知:config set notify-keyspace-events Ex

func (*Redis) SubscribeAllEvents

func (r *Redis) SubscribeAllEvents(pb func(message string))

SubscribeAllEvents 订阅所有键过期事件

Jump to

Keyboard shortcuts

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