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

reqmemo

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package reqmemo memoizes point reads for the length of one read request.

A list page builds each item with the same helpers, and several of them read the same row (a viewer's track rules, a server setting, a title's resume record) once per item, or several times per item. The app attaches a memo to every GET and HEAD request; a helper that reads through Do asks the database once per key per request. Without a memo (a background job, a write request) Do just loads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do[T any](ctx context.Context, key string, load func() (T, error)) (T, error)

Do returns the memoized value for key, or loads, remembers and returns it. A failed load is not remembered. Callers must not change a returned value that other callers share (copy slices and maps before changing them).

func Forget

func Forget(ctx context.Context, key string)

Forget drops key, for a request that writes what it read.

func ForgetPrefix

func ForgetPrefix(ctx context.Context, prefix string)

ForgetPrefix drops every key starting with prefix.

func With

func With(ctx context.Context) context.Context

With attaches an empty memo to ctx.

Types

This section is empty.

Jump to

Keyboard shortcuts

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