cache

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 4 Imported by: ? 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultCache

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

DefaultCache is the default cache implementation using sync.Map for thread-safe concurrent access.

func NewDefaultCache

func NewDefaultCache() *DefaultCache

NewDefaultCache creates a new DefaultCache with an initialized sync.Map.

func (*DefaultCache) Load

func (c *DefaultCache) Load(key uint64) (*SchemaCacheEntry, bool)

Load retrieves a schema from the cache.

func (*DefaultCache) Range

func (c *DefaultCache) Range(f func(key uint64, value *SchemaCacheEntry) bool)

Range calls f for each entry in the cache (for testing/inspection).

func (*DefaultCache) Store

func (c *DefaultCache) Store(key uint64, value *SchemaCacheEntry)

Store saves a schema to the cache.

type SchemaCache

type SchemaCache interface {
	Load(key uint64) (*SchemaCacheEntry, bool)
	Store(key uint64, value *SchemaCacheEntry)
	Range(f func(key uint64, value *SchemaCacheEntry) bool)
}

SchemaCache defines the interface for schema caching implementations. The key is a uint64 hash of the schema (from schema.GoLow().Hash()).

type SchemaCacheEntry

type SchemaCacheEntry struct {
	Schema          *base.Schema
	RenderedInline  []byte
	ReferenceSchema string // String version of RenderedInline
	RenderedJSON    []byte
	CompiledSchema  *jsonschema.Schema
	RenderedNode    *yaml.Node
}

SchemaCacheEntry holds a compiled schema and its intermediate representations. This is stored in the cache to avoid re-rendering and re-compiling schemas on each request.

Jump to

Keyboard shortcuts

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