cache

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const GlobalEvent = "global_event"

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Set(k, v string, expires time.Duration) error
	Get(k string) (string, error)
}

type Redis

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

func NewRedis

func NewRedis(options RedisOptions) *Redis

func (*Redis) Get

func (r *Redis) Get(k string) (string, error)

func (*Redis) GetOriginPoint

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

GetOriginPoint 获取原始redis实例

func (*Redis) Set

func (r *Redis) Set(k, v string, expires time.Duration) 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 订阅所有键过期事件

type RedisOptions

type RedisOptions struct {
	Addr     string
	Password string
	DB       int
}

Jump to

Keyboard shortcuts

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