cache

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package cache provides the ability to cache expensive resources

The cache is intended to not only cache HTTP response; but also expensive processing performed on the response. E.g., parsing JavaScript into a compiled AST.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[T any](c *Cache, key string) (res T, ok bool)

Get returns a resource from the cache found by key, assignable to type T. If key is not found, or the type is not T, ok will be false. Panics if c is nil.

func Set

func Set[T any](c *Cache, key string, val T)

Set adds a to the cache with the specified key. If the key already exists, the value is overwritten. Panics if c is nil.

Types

type Cache

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

Cache provides a simple cache of expensive resources. This is intended for a narrow scope, where a well-known set of resources can be cached. The cache has no eviction policy, so any cached resource will be kept indefinitely.

One example use case is to cached parsed JavaScript that is installed as polyfill in the browser.

Jump to

Keyboard shortcuts

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