cache

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache(pool *predis.Pool, secTimer *timewheel.TimeWheel) (*Cache, error)

func (*Cache) AddOrUpdate

func (cache *Cache) AddOrUpdate(key, value string, signature [8]byte, expireSec int64,
	keepaliveSec int64, keepaliveRetry int, retryDelaySec int64, callback KeepaliveCallback) (*KeepaliveTask, error)

AddOrUpdate

@Description: 添加或更新
@receiver cache
@param key
@param value
@param signature 签名
@param expireSec 过期时间
@param keepaliveSec 保活间隔时间
@param keepaliveRetry 保活失败重试次数
@param retryDelaySec 保活失败重试延迟
@param callback 保活结果回调
@return *KeepaliveTask 保活任务对象,可以通过该对象取消
@return error

func (*Cache) Delete

func (cache *Cache) Delete(key string, signature [8]byte) error

Delete

@Description: 删除指定key值
@receiver cache
@param key
@param signature 签名,不能删除非自己维护的缓存
@return error

func (*Cache) Get

func (cache *Cache) Get(key string) (string, bool, error)

Get

@Description: 获取当前值
@receiver cache
@param key
@return string 值
@return bool 缓存是否存在
@return error 错误

type KeepaliveCallback

type KeepaliveCallback func(result error, retryCount int)

type KeepaliveTask

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

func (*KeepaliveTask) Cancel

func (task *KeepaliveTask) Cancel()

Jump to

Keyboard shortcuts

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