{"modulePath":"github.com/pb33f/libopenapi-validator","version":"v0.16.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package cache\n\n## Types\n\n```go\ntype DefaultCache struct {\n\t// contains filtered or unexported fields\n}\n```\nDefaultCache is the default cache implementation using sync.Map for thread-safe concurrent access.\n\n```go\nfunc NewDefaultCache() *DefaultCache\n```\nNewDefaultCache creates a new DefaultCache with an initialized sync.Map.\n\n```go\nfunc (c *DefaultCache) Load(key uint64) (*SchemaCacheEntry, bool)\n```\nLoad retrieves a schema from the cache.\n\n```go\nfunc (c *DefaultCache) Range(f func(key uint64, value *SchemaCacheEntry) bool)\n```\nRange calls f for each entry in the cache (for testing/inspection).\n\n```go\nfunc (c *DefaultCache) Release()\n```\nRelease clears all cached schema entries.\n\n```go\nfunc (c *DefaultCache) Store(key uint64, value *SchemaCacheEntry)\n```\nStore saves a schema to the cache.\n\n```go\ntype DefaultSchemaResourceCache struct {\n\t// contains filtered or unexported fields\n}\n```\nDefaultSchemaResourceCache is the default thread-safe cache for rendered document resources.\n\n```go\nfunc NewDefaultSchemaResourceCache() *DefaultSchemaResourceCache\n```\nNewDefaultSchemaResourceCache creates a default cache for rendered document resources.\n\n```go\nfunc (c *DefaultSchemaResourceCache) Load(key string) (*SchemaResourceCacheEntry, bool)\n```\nLoad retrieves a rendered document resource from the cache.\n\n```go\nfunc (c *DefaultSchemaResourceCache) Range(f func(key string, value *SchemaResourceCacheEntry) bool)\n```\nRange calls f for each rendered document resource cache entry.\n\n```go\nfunc (c *DefaultSchemaResourceCache) Release()\n```\nRelease clears all cached rendered document resources.\n\n```go\nfunc (c *DefaultSchemaResourceCache) Store(key string, value *SchemaResourceCacheEntry)\n```\nStore saves a rendered document resource to the cache.\n\n```go\ntype SchemaCache interface {\n\tLoad(key uint64) (*SchemaCacheEntry, bool)\n\tStore(key uint64, value *SchemaCacheEntry)\n\tRange(f func(key uint64, value *SchemaCacheEntry) bool)\n}\n```\nSchemaCache defines the interface for schema caching implementations. The key is a uint64 hash of the schema (from schema.GoLow().Hash()).\n\n```go\ntype SchemaCacheEntry struct {\n\tSchema          *base.Schema\n\tRenderedInline  []byte\n\tReferenceSchema string // String version of RenderedInline\n\tRenderedJSON    []byte\n\tCompiledSchema  *jsonschema.Schema\n\tRenderedNode    *yaml.Node\n\tResourceNodes   map[string]*yaml.Node\n}\n```\nSchemaCacheEntry 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.\n\n```go\ntype SchemaResourceCache interface {\n\tLoad(key string) (*SchemaResourceCacheEntry, bool)\n\tStore(key string, value *SchemaResourceCacheEntry)\n\tRange(f func(key string, value *SchemaResourceCacheEntry) bool)\n\tRelease()\n}\n```\nSchemaResourceCache caches rendered document resources by parsed document identity. Entries are immutable once stored; implementations must be safe for concurrent use.\n\n```go\ntype SchemaResourceCacheEntry struct {\n\tRenderedInline  []byte\n\tReferenceSchema string\n\tRenderedJSON    []byte\n\tRenderedNode    *yaml.Node\n\tSourceRootNode  *yaml.Node // Keeps pointer-identity cache keys live for the cache entry lifetime.\n}\n```\nSchemaResourceCacheEntry 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.\n\n","path":"github.com/pb33f/libopenapi-validator/cache","name":"cache","synopsis":"","isRedistributable":true}
