Documentation
¶
Overview ¶
Package schemas provides a thread-safe, in-memory cache for JSON schemas used during STAC object validation. Schemas are fetched from the network on first use and stored in a sync.Map so that subsequent validations can reuse the compiled schema without additional I/O or compilation overhead.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache holds compiled JSON schemas keyed by their canonical URL string. It is safe to call any method concurrently.
func NewCache ¶
func NewCache() *Cache
NewCache returns an initialised Cache whose compiler is pre-configured to load remote schemas over HTTP when they are not already cached.
func (*Cache) Get ¶
func (c *Cache) Get(schemaURL string) (*jsonschema.Schema, error)
Get returns the compiled schema for the given URL, compiling and caching it if this is the first request for that URL. It uses a double-checked locking pattern: a lock-free fast path for the common case (schema already cached) and a mutex-guarded slow path to ensure the underlying compiler — which mutates internal state — is never called from two goroutines simultaneously.