cache

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 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) Release added in v0.13.13

func (c *DefaultCache) Release()

Release clears all cached schema entries.

func (*DefaultCache) Store

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

Store saves a schema to the cache.

type DefaultSchemaResourceCache added in v0.13.13

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

DefaultSchemaResourceCache is the default thread-safe cache for rendered document resources.

func NewDefaultSchemaResourceCache added in v0.13.13

func NewDefaultSchemaResourceCache() *DefaultSchemaResourceCache

NewDefaultSchemaResourceCache creates a default cache for rendered document resources.

func (*DefaultSchemaResourceCache) Load added in v0.13.13

Load retrieves a rendered document resource from the cache.

func (*DefaultSchemaResourceCache) Range added in v0.13.13

func (c *DefaultSchemaResourceCache) Range(f func(key string, value *SchemaResourceCacheEntry) bool)

Range calls f for each rendered document resource cache entry.

func (*DefaultSchemaResourceCache) Release added in v0.13.13

func (c *DefaultSchemaResourceCache) Release()

Release clears all cached rendered document resources.

func (*DefaultSchemaResourceCache) Store added in v0.13.13

Store saves a rendered document resource 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
	ResourceNodes   map[string]*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.

type SchemaResourceCache added in v0.13.13

type SchemaResourceCache interface {
	Load(key string) (*SchemaResourceCacheEntry, bool)
	Store(key string, value *SchemaResourceCacheEntry)
	Range(f func(key string, value *SchemaResourceCacheEntry) bool)
	Release()
}

SchemaResourceCache caches rendered document resources by parsed document identity. Entries are immutable once stored; implementations must be safe for concurrent use.

type SchemaResourceCacheEntry added in v0.13.13

type SchemaResourceCacheEntry struct {
	RenderedInline  []byte
	ReferenceSchema string
	RenderedJSON    []byte
	RenderedNode    *yaml.Node
	SourceRootNode  *yaml.Node // Keeps pointer-identity cache keys live for the cache entry lifetime.
}

SchemaResourceCacheEntry holds one rendered document-level JSON Schema resource. Resource entries are shared by many compiled schema entry points from the same parsed document. RenderedNode may point at source YAML for generic validation; consumers must treat it as read-only.

Jump to

Keyboard shortcuts

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