cache

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load[T any](key string, newValue func(key string) T) T

Load load value by key from default cache pool uses a default ttl value

func LoadTTL

func LoadTTL[T any](key string, ttl time.Duration, newValue func(key string) T) T

LoadTTL load value by key from default cache pool if value's ttl is expired, will exec {newValue} create a new value

Types

type CacheValue

type CacheValue[T any] struct {
	// contains filtered or unexported fields
}

func (*CacheValue[T]) Load

func (v *CacheValue[T]) Load(newValue func() T) T

func (*CacheValue[T]) LoadTTL

func (v *CacheValue[T]) LoadTTL(ttl time.Duration, newValue func() T) T

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳