Skip to main content

Module cache

Module cache 

Source
Expand description

Content fingerprinting for incremental builds. Content fingerprinting for incremental builds.

This module provides BuildCache, which tracks SHA-256-style fingerprints of content files so that only files modified since the last build need to be re-processed.

§Overview

  1. On startup, call BuildCache::load to read the previous fingerprint map from .ssg-cache.json.
  2. Call BuildCache::changed_files with the content directory to obtain the list of files whose contents have changed (or are new).
  3. After a successful build, call BuildCache::update to record the current fingerprints, then BuildCache::save to persist them to disk.

§Example

use std::path::Path;
use ssg::cache::BuildCache;

let cache_path = Path::new(".ssg-cache.json");
let content_dir = Path::new("content");

let mut cache = BuildCache::load(cache_path).unwrap();
let changed = cache.changed_files(content_dir).unwrap();

// … build only `changed` files …

cache.update(content_dir).unwrap();
cache.save().unwrap();

Structs§

BuildCache
Persisted fingerprint map used for incremental builds.