Note

This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the user guide for the big picture.

biolearn.cache.LocalFolderCache

class biolearn.cache.LocalFolderCache(path: str, max_size_gb: float)

LRU-style cache that stores pickled objects in a local directory.

__init__(path: str, max_size_gb: float)

Initialize the LocalFolderCache.

Parameters:
  • path – Directory path for storing cache files.

  • max_size_gb – Maximum total cache size in gigabytes.

get(key: str, category: str, version: str) Any | None

Retrieve a cached value.

Parameters:
  • key – Unique key identifying the cache entry.

  • category – Cache category name.

  • version – Version string for invalidation.

Returns:

The cached object, or None if not found or on load error.

store(key: str, value: Any, category: str, version: str) None

Store a value in the cache under the given key/category/version.

Parameters:
  • key – Unique key identifying the cache entry.

  • value – Object to store.

  • category – Cache category name.

  • version – Version string for invalidation.

Notes

If the serialized object exceeds the cache size limit, it will not be stored. Before storing, stale files in the same category but different version are removed.

clear() None

Remove all cache files.

Parameters:

None

remove(key: str) None

Remove cache files matching the given key across categories and versions.

Parameters:

key – Unique key identifying entries to remove.