Skip to main content

Module cache

Module cache 

Source
Expand description

Caching module for eure.

This module provides caching infrastructure with support for multiple cache types.

§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 the platform-specific cache directory (via directories crate):

  • macOS: ~/Library/Caches/dev.eure.eure/
  • Linux: ~/.cache/eure/
  • Windows: C:\Users\<User>\AppData\Local\eure\eure\cache\

Override with $EURE_CACHE_DIR environment variable.

Cache types are stored in subdirectories:

~/Library/Caches/dev.eure.eure/  # base_cache_dir() (macOS example)
  https/                          # https_cache_dir() - HTTPS fetched content
    eure.dev/
      a1/
        b2/
          a1b2c3d4-schema.eure       # content
          a1b2c3d4-schema.eure.meta  # metadata (JSON)
  # (future: compile/, build/, etc.)

§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.