xfreecache

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Byte Size = 1
	KB        = 1024 * Byte
	MB        = 1024 * KB
	GB        = 1024 * MB
	TB        = 1024 * GB
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Size          Size          // 缓存容量,最小512*1024 【必填】
	Expire        time.Duration // 失效时间 【必填】
	DisableMetric bool          // metric上报 false 开启  ture 关闭【选填,默认开启】
	Name          string        // 本地缓存名称,用于日志标识&metric上报【选填】
}

func DefaultConfig

func DefaultConfig() Config

DefaultConfig 返回默认配置

func (Config) Build

func (c Config) Build() (localCache *LocalCache)

Build 构建本地缓存实例 The entry size need less than 1/1024 of cache size

type LocalCache

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

func (*LocalCache) GetAndSetCacheData

func (c *LocalCache) GetAndSetCacheData(key string, fn func() ([]byte, error)) (v []byte, err error)

GetAndSetCacheData 获取缓存后数据

type Size

type Size int

Jump to

Keyboard shortcuts

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