cache

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[K comparable, V any] interface {
	Get(key K, fn func() (V, error)) (V, error)
}

Cache is interface for cache

type Impl

type Impl[K comparable, T any] struct {
	// contains filtered or unexported fields
}

func New

func New[K comparable, T any]() *Impl[K, T]

New makes a Impl instance.

func (*Impl[K, T]) Get

func (g *Impl[K, T]) Get(key K, fn func() (T, error)) (T, error)

Get returns the initialized value by key, and make sure the value will be initialized only once.

Jump to

Keyboard shortcuts

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