<!-- Source: https://docs.squirro.com/en/latest/api/squirro.lib.nlp.utils.cache.ModelCacheClient.html -->
# ModelCacheClient

**`class ModelCacheClient(cache_client=None, expiration=3600)`**

Bases: [`object`](https://docs.python.org/3.11/library/functions.html#object)

Cache client to enable model sharing across whole process.

The client by default uses shared memory cache with expiration that allows storing
models in memory, reuse them and free up space when the model is unused for a
certain period of time. It also provides a lock to prevent downloading the same
model by parallel executions.

Attributes SummaryMethods SummaryAttributes Documentation

**`LOADING_MODELS_CACHE_KEY = '__loading_models'`**

**`WAIT_FOR_LOADING_MODEL_ITERATIONS = 60`**

**`WAIT_FOR_LOADING_MODEL_SLEEP_SECS = 0.5`**

Methods Documentation

**`get_and_save_model(name, load_func)`**

Return type

[`TypeVar`](https://docs.python.org/3.11/library/typing.html#typing.TypeVar)(`Model`)

**`get_model(name)`**

Return type

[`Optional`](https://docs.python.org/3.11/library/typing.html#typing.Optional)[[`Any`](https://docs.python.org/3.11/library/typing.html#typing.Any)]

**`save_model(name, model)`**

Return type

[`None`](https://docs.python.org/3.11/library/constants.html#None)
