Documentation
¶
Index ¶
- type DefaultCache
- type DefaultSchemaResourceCache
- func (c *DefaultSchemaResourceCache) Load(key string) (*SchemaResourceCacheEntry, bool)
- func (c *DefaultSchemaResourceCache) Range(f func(key string, value *SchemaResourceCacheEntry) bool)
- func (c *DefaultSchemaResourceCache) Release()
- func (c *DefaultSchemaResourceCache) Store(key string, value *SchemaResourceCacheEntry)
- type SchemaCache
- type SchemaCacheEntry
- type SchemaResourceCache
- type SchemaResourceCacheEntry
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
func (c *DefaultSchemaResourceCache) Load(key string) (*SchemaResourceCacheEntry, bool)
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
func (c *DefaultSchemaResourceCache) Store(key string, value *SchemaResourceCacheEntry)
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.