cached

package
v0.0.0-...-9e605f1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionRedisSync

func ActionRedisSync(time time.Duration, f func(client redis2.UniversalClient) error)

func CacheAndRedisGet

func CacheAndRedisGet(ctx context.Context, key string, obj interface{}) (bool, error)

CacheAndRedisGet 从内存缓存和redis中获取数据

func Get

func Get(ctx context.Context, key string) (string, bool, error)

读取字符串缓存,其中找到了返回true,没找到或者异常返回false

func GetWithFunc

func GetWithFunc(ctx context.Context, key string, f func(ctx context.Context, key string) (string, error)) (string, error)

GetWithFunc 从缓存中获取字符串,如果没有就调用func函数获取

func ScanGet

func ScanGet(ctx context.Context, key string, obj interface{}, collectionName string) (bool, error)

func ScanTagDelete

func ScanTagDelete(ctx context.Context, key string, obj interface{})

ScanTagDelete 将缓存值标记为删除,下次从cache读取时会回调到数据库

func ScanWriteCache

func ScanWriteCache(ctx context.Context, key string, obj interface{}, state bool) (err error)

ScanWriteCache 将数据写入缓存,如果state为false,那么只写入本地缓存,否则同时写入redis

func TagDelete

func TagDelete(ctx context.Context, key string)

TagDelete 删除字符串缓存 与ScanTagDelete不一样,这里是直接删除键值对,而ScanTagDelete是打标记然后等待下一次访问的时候更新

func Write

func Write(ctx context.Context, key string, value string, state bool)

Write 写入字符串缓存,如果state为false,那么只写入本地缓存,否则同时写入redis

Types

type TimeTicker

type TimeTicker struct {
	Tick *time.Ticker
	Work func(client redis2.UniversalClient) error
}

func NewTick

func NewTick(interval time.Duration, f func(client redis2.UniversalClient) error) *TimeTicker

func (*TimeTicker) Start

func (t *TimeTicker) Start()

Jump to

Keyboard shortcuts

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