clientkey

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package key redis的key包装

Package key redis的key包装

Index

Constants

This section is empty.

Variables

View Source
var ErrAutoRefreshTaskHNotSetYet = errors.New("自动刷新任务未启动")

ErrAutoRefreshTaskHNotSetYet 自动刷新任务未启动

View Source
var ErrAutoRefreshTaskHasBeenSet = errors.New("已经启动了自动刷新任务")

ErrAutoRefreshTaskHasBeenSet 已经启动了自动刷新任务

View Source
var ErrAutoRefreshTaskInterval = errors.New("未设置自动刷新任务的间隔")

ErrAutoRefreshTaskInterval 未设置自动刷新任务的间隔

View Source
var ErrKeyNotExist = errors.New("key不存在")

ErrKeyNotExist key不存在

View Source
var ErrKeyNotSetExpire = errors.New("key没有设置过期")

ErrKeyNotSetExpire key没有设置过期

View Source
var ErrKeyNotSetMaxTLL = errors.New("key没有设置最大tll")

ErrKeyNotSetMaxTLL key没有设置最大tll

View Source
var ErrParamDelimiterLengthMustLessThan2 = errors.New("不定长参数delimiter长度必须小于2")

ErrParamDelimiterLengthMustLessThan2 不定长参数delimiter长度必须小于2

Functions

This section is empty.

Types

type ClientKey

type ClientKey struct {
	Key string
	Opt Options

	Client redis.UniversalClient
	// contains filtered or unexported fields
}

ClientKey 描述任意一种的单个key对象

func New

func New(client redis.UniversalClient, key string, opts ...Option) *ClientKey

New 创建一个新的key对象 @params client redis.UniversalClient 客户端对象 @params key string bitmap使用的key @params opts ...*KeyOption key的选项

func (*ClientKey) AutoRefresh

func (k *ClientKey) AutoRefresh() error

AutoRefresh 自动刷新key的过期时间

func (*ClientKey) Delete

func (k *ClientKey) Delete(ctx context.Context) error

Delete 删除key @params ctx context.Context 上下文信息,用于控制请求的结束

func (*ClientKey) Exists

func (k *ClientKey) Exists(ctx context.Context) (bool, error)

Exists 查看key是否存在 @params ctx context.Context 上下文信息,用于控制请求的结束

func (*ClientKey) RefreshTTL

func (k *ClientKey) RefreshTTL(ctx context.Context) error

RefreshTTL 刷新key的生存时间 @params ctx context.Context 上下文信息,用于控制请求的结束

func (*ClientKey) StopAutoRefresh

func (k *ClientKey) StopAutoRefresh(force bool) error

StopAutoRefresh 取消自动更新缓存 @params force bool 强制停下整个定时任务cron对象

func (*ClientKey) TTL

func (k *ClientKey) TTL(ctx context.Context) (time.Duration, error)

TTL 查看key的剩余时间 @params ctx context.Context 上下文信息,用于控制请求的结束

func (*ClientKey) Type

func (k *ClientKey) Type(ctx context.Context) (string, error)

Type 查看key的类型 @params ctx context.Context 上下文信息,用于控制请求的结束

type Option

type Option interface {
	Apply(*Options)
}

Option configures how we set up the connection.

func WithAutoRefreshInterval

func WithAutoRefreshInterval(autoRefreshInterval string) Option

WithAutoRefreshInterval 设置自动刷新过期时间的设置

func WithMaxTTL

func WithMaxTTL(maxttl time.Duration) Option

WithMaxTTL 设置最大过期时间

func WithTaskCron

func WithTaskCron(taskCron *cron.Cron) Option

WithTaskCron 设置定时器

type Options

type Options struct {
	MaxTTL              time.Duration
	AutoRefreshInterval string
	TaskCron            *cron.Cron
}

Option 设置key行为的选项 @attribute MaxTTL time.Duration 为0则不设置过期 @attribute AutoRefresh string 需要为crontab格式的字符串,否则不会自动定时刷新

Directories

Path Synopsis
Package clientkeybatch redis的keybatch包装
Package clientkeybatch redis的keybatch包装

Jump to

Keyboard shortcuts

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