gchar.utils.cache

optional_lru_cache

gchar.utils.cache.optional_lru_cache(*pargs, **pkwargs)[source]

Decorator that optionally applies LRU caching to a function’s return value based on the presence of the ‘NO_CACHE’ environment variable.

The function is decorated with the lru_cache decorator with the provided arguments pargs and pkwargs to enable caching. However, if the ‘NO_CACHE’ environment variable is present, the original function is called directly without caching.

Parameters:
  • pargs (tuple) – Positional arguments to be passed to the lru_cache decorator.

  • pkwargs (dict) – Keyword arguments to be passed to the lru_cache decorator.

Returns:

Decorated function.

Return type:

callable