Help us shape the future of Go! Take the 2026 Go Developer Survey

cache

package
v0.34.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package cache keeps source answers for their TTL and runs one fetch per key at a time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func New

func New() *Cache

func (*Cache) Forget

func (c *Cache) Forget(key string)

func (*Cache) Get

func (c *Cache) Get(key string, ttl time.Duration, fetch func() (any, error)) (any, error)

Get answers from the cache while key's value is younger than ttl, else fetches once for every caller waiting on key. Errors are not kept.

Jump to

Keyboard shortcuts

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