cache

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: MIT Imports: 3 Imported by: 0

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 [32]byte) (*SchemaCacheEntry, bool)

Load retrieves a schema from the cache.

func (*DefaultCache) Range

func (c *DefaultCache) Range(f func(key [32]byte, value *SchemaCacheEntry) bool)

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

func (*DefaultCache) Store

func (c *DefaultCache) Store(key [32]byte, value *SchemaCacheEntry)

Store saves a schema to the cache.

type SchemaCache

type SchemaCache interface {
	Load(key [32]byte) (*SchemaCacheEntry, bool)
	Store(key [32]byte, value *SchemaCacheEntry)
	Range(f func(key [32]byte, value *SchemaCacheEntry) bool)
}

SchemaCache defines the interface for schema caching implementations. The key is a [32]byte 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
}

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