caches

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: MIT Imports: 3 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface[T any] interface {
	// Remember value by key. If key is exists and ttl is not expired then return value without call callback.
	// If key is not exists or ttl is expired then call callback and remember value by key.
	// Error is returned from callback if failed.
	Remember(key string, ttlS uint64, callback func() (T, error)) (T, error)

	// Clear all cache.
	Clear()

	// Forget cache value by key.
	Forget(key string) (T, error)

	// Get length of cache.
	Length() uint64
}

func NewCache

func NewCache[T any]() Interface[T]

Jump to

Keyboard shortcuts

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