freshness

package
v0.0.0-...-e42dbd5 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package freshness 实现一个新鲜度 map, 新鲜度指的是存取时间的新鲜度, 如果一个值经常被存取, 可能永远不会过期

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map[K constraints.Ordered, V any] interface {
	Get(key K) (V, bool)
	Set(key K, value V) (swapped bool)
	GetOrNew(key K) (V, bool, error)
	Close()
}

Map 实现一个新鲜度 map

func NewMap

func NewMap[K constraints.Ordered, V any](opts ...Option) Map[K, V]

type Option

type Option func(*options)

func WithDebug

func WithDebug(f func(string, ...any)) Option

func WithExpireCallback

func WithExpireCallback[K constraints.Ordered, V any](f func(key K, value V)) Option

func WithNewer

func WithNewer[K constraints.Ordered, V any](f func(key K) (V, error)) Option

func WithRenewTime

func WithRenewTime(tm time.Duration) Option

func WithTimeout

func WithTimeout(tm time.Duration) Option

Jump to

Keyboard shortcuts

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