cache

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheData

type CacheData struct {
	ExpireAt int64  // ExpireAt 失效时间
	Data     string // Data 真实数据
}

CacheData cache data struct

type Cacher

type Cacher interface {
	// GetData load data from cache
	// if cache not exist load data by LoadFunc
	// expiration is redis server expiration
	// ttl is developer expiration
	GetData(ctx context.Context, key string, expiration time.Duration, ttl time.Duration, f LoadFunc, data interface{}) (err error)

	// FlushCache flush cache
	// if cache not exist, load data and save cache
	FlushCache(ctx context.Context, key string, expiration time.Duration, ttl time.Duration, f LoadFunc, data interface{}) (err error)
}

type LoadFunc

type LoadFunc func(ctx context.Context, target interface{}) (err error)

LoadFunc define load data func

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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