Module

cache.version

Cache version management with magic header validation.

Adopted from Jinja2's bytecode cache pattern to ensure robust cache invalidation across Python and Bengal version upgrades.

Classes

CacheVersion 5
Parsed cache version info.

Parsed cache version info.

Attributes

Name Type Description
format_version int
python_major int
python_minor int

Methods

current 0 CacheVersion
Get the current environment's cache version info.
classmethod
def current(cls) -> CacheVersion
Returns
CacheVersion
is_compatible 0 bool
Check if this version is compatible with current runtime.
def is_compatible(self) -> bool
Returns
bool

Functions

validate_cache_header 1 tuple[bool, bytes]
Validate cache magic header and return remaining data.
def validate_cache_header(data: bytes) -> tuple[bool, bytes]
Parameters
Name Type Description
data bytes
Returns
tuple[bool, bytes]
prepend_cache_header 1 bytes
Prepend magic header to cache data.
def prepend_cache_header(data: bytes) -> bytes
Parameters
Name Type Description
data bytes
Returns
bytes