pub struct ValidationCache { /* private fields */ }Expand description
A disk-backed cache for JSON Schema validation results.
Results are keyed by SHA-256(crate_version + file_content + schema_json + validate_formats_byte).
Cache files are stored as <cache_dir>/<sha256-hex>.json.
Implementations§
Source§impl ValidationCache
impl ValidationCache
pub fn new(cache_dir: PathBuf, skip_read: bool) -> Self
Sourcepub async fn lookup(
&self,
file_content: &str,
schema_hash: &str,
validate_formats: bool,
) -> (Option<Vec<ValidationError>>, ValidationCacheStatus)
pub async fn lookup( &self, file_content: &str, schema_hash: &str, validate_formats: bool, ) -> (Option<Vec<ValidationError>>, ValidationCacheStatus)
Look up a cached validation result.
Returns (Some(errors), Hit) on cache hit.
Returns (None, Miss) on cache miss or when skip_read is set.
schema_hash should be obtained from schema_hash — pass the same
value for all files in a schema group to avoid redundant serialization.
Sourcepub async fn store(
&self,
file_content: &str,
schema_hash: &str,
validate_formats: bool,
errors: &[ValidationError],
)
pub async fn store( &self, file_content: &str, schema_hash: &str, validate_formats: bool, errors: &[ValidationError], )
Store a validation result to the disk cache.
Always writes regardless of skip_read, so running with
--force-validation repopulates the cache for future runs.
schema_hash should be obtained from schema_hash — pass the same
value for all files in a schema group to avoid redundant serialization.
Sourcepub fn cache_key(
file_content: &str,
schema_hash: &str,
validate_formats: bool,
) -> String
pub fn cache_key( file_content: &str, schema_hash: &str, validate_formats: bool, ) -> String
Compute the SHA-256 cache key from file content, a pre-computed schema hash, and format flag.
The crate version is included in the hash so that upgrading lintel automatically invalidates stale cache entries.
Trait Implementations§
Source§impl Clone for ValidationCache
impl Clone for ValidationCache
Source§fn clone(&self) -> ValidationCache
fn clone(&self) -> ValidationCache
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more