xfreecache

package
v0.0.0-...-a89d410 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 15 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

func New

func New[K comparable, V any](c *Config) (localCache *cache.Cache[K, V])

New 构建本地缓存实例 缓存容量默认256MB 最小512KB 最大8GB

func StdNew

func StdNew[K comparable, V any](name string) (localCache *cache.Cache[K, V])

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

Types

type Config

type Config struct {
	Cache         *freecache.Cache `json:"-" toml:"-"`                         // 本地缓存实例【必填】
	Expire        time.Duration    `json:"expire" toml:"expire"`               // 失效时间 【必填】
	DisableMetric bool             `json:"disableMetric" toml:"disableMetric"` // metric上报 false 开启  ture 关闭【选填,默认开启】
	Name          string           `json:"-" toml:"-"`                         // 本地缓存名称,用于日志标识&metric上报【选填】
}

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig 返回默认配置

func StdConfig

func StdConfig(name string) *Config

StdConfig 返回标准配置

type Size

type Size int

func ParseSize

func ParseSize(s string) (Size, error)

ParseSize parses a size string. Valid time units are "b" (or "byte"), "kb", "mb", "gb", "tb".

Jump to

Keyboard shortcuts

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