cache

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cache holds the small expiring cache used wherever the app asks an endpoint one batched question and wants to remember the answer for a while: label resolution and rdf:type lookup after a query returns (internal/sparql), and full-text connector discovery before one is built (internal/search).

They all do the same thing, so they share one implementation and one sweeper goroutine rather than keeping a near-identical copy each.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

Init starts the background sweeper, once per process. Called from the paths that populate a cache rather than an init() so a process that never queries (tests, the index builder) does not spawn a goroutine it has no use for.

Types

type TTL

type TTL[V any] struct {
	// contains filtered or unexported fields
}

TTL is a concurrent map whose entries expire.

Expired entries are dropped on read, so correctness never depends on the sweeper; the sweeper exists only to stop entries that are never read again from pinning memory forever.

func New

func New[V any](ttl time.Duration) *TTL[V]

New returns a cache and registers it with the shared sweeper. Call it from a package-level var so registration happens before any request runs.

func (*TTL[V]) Get

func (c *TTL[V]) Get(key string) (V, bool)

func (*TTL[V]) Set

func (c *TTL[V]) Set(key string, value V)

Jump to

Keyboard shortcuts

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