simvx.core.assets.cache

Byte-budget LRU cache used by typed loaders.

Keys are (uri, version) so the same URI with a new version (etag, mtime) becomes a fresh entry; consumers don’t need explicit invalidation to pick up updated content.

Module Contents

Classes

LRUCache

Simple byte-budget LRU.

API

class simvx.core.assets.cache.LRUCache(max_bytes: int)[source]

Simple byte-budget LRU.

Estimates per-entry size via sys.getsizeof for bytes-like values and falls back to a constant for arbitrary objects. Loaders that cache structured assets (textures, sounds) should pass size_hint so eviction tracks GPU/audio memory rather than the Python wrapper.

Initialization

__len__() int[source]
property used_bytes: int[source]
get(uri: str, version: str | None) Any | None[source]
put(uri: str, version: str | None, value: Any, size_hint: int | None = None) None[source]
invalidate(uri: str, version: str | None = None) None[source]

Drop one entry. If version is None, drop every version of uri.

clear() None[source]