class Bakelite::Transform::Cache

Overview

Content-addressable cache manager for compile-time asset transformations. Caches the results of expensive external tool executions in .bakelite/cache/ keyed by SHA256(file_content + command_string), eliminating repeated process invocations.

Defined in:

bakelite/transform/cache.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(cache_dir : Path | String = ".bakelite/cache") #

Instance Method Detail

def cache_dir : Path #

def cache_file_path(key : String) : Path #

Full path to the cache entry file.


def clear : Nil #

Clears all entries in the cache directory.


def compute_key(input_data : Bytes | String, command : String) : String #

Computes a deterministic cache key from input bytes and transform command string.


def get?(key : String) : Bytes | Nil #

Retrieves cached output bytes, returning nil on cache miss.


def has_key?(key : String) : Bool #

Checks if a transformed result exists in cache.


def put(key : String, data : Bytes | String) : Nil #

Stores transformed output bytes into cache.