Module cache

Module cache 

Source
Expand description

Remote schema caching module.

This module provides caching for remote schema files fetched over HTTP(S).

§Module Organization

  • Core types (always available): CacheMeta, CacheKeyInfo, path computation
  • Native I/O (requires native feature): fetch, FsStorage, gc

§Cache Layout

The cache is stored in ~/.cache/eure/schemas/ (or $EURE_CACHE_DIR). Files are organized with 2-level directory sharding to prevent overcrowding:

~/.cache/eure/schemas/
  eure.dev/
    a1/
      b2/
        a1b2c3d4-eure-schema.schema.eure       # content
        a1b2c3d4-eure-schema.schema.eure.meta  # metadata (JSON)

§Example (native only)

use url::Url;
use eure_env::cache::{fetch, CacheOptions};

let url = Url::parse("https://eure.dev/v0.1.0/schemas/eure-schema.schema.eure").unwrap();
let result = fetch(&url, &CacheOptions::default()).unwrap();
println!("Content: {}", result.content);
println!("From cache: {}", result.from_cache);

Structs§

CacheKeyInfo
Information about a cache key derived from a URL.
CacheMeta
Metadata for a cached file.
ConditionalHeaders
Conditional GET headers.

Enums§

CacheAction
Result of checking cache freshness.

Functions§

compute_cache_key
Compute cache key information from a URL.
compute_content_hash
Compute SHA256 hash of content and return as hex string.
lock_path
Get the lock file path for a cache file.
meta_path
Get the meta file path for a cache file.
url_to_cache_path
Convert URL to full cache file path.