API

Although the high-level boto3-client-cache API (boto3_client_cache.session) is ergonomically identical to boto3’s client, resource, and session interfaces, the primary interfaces for boto3-client-cache are boto3_client_cache.cache.ClientCache and boto3_client_cache.cache.ResourceCache, which come from the low-level API (boto3_client_cache.cache) and can be used to cache and retrieve boto3 clients and resources efficiently. Whether under the hood of the high-level API or when used directly, these classes manage an in-memory cache of boto3 clients and resources, allowing for quick retrieval and reuse of these objects across multiple calls. The cache is designed to be thread-safe and supports LRU and LFU eviction policies.

boto3_client_cache.cache.ClientCache and boto3_client_cache.cache.ResourceCache can be used exactly like a standard Python dictionary, with the exception of the fromkeys, update, and setdefault methods, as well as the |= and | operator.

Important

To interact with the cache(s) directly, you must use the boto3_client_cache.cache.ClientCacheKey or boto3_client_cache.cache.ResourceCacheKey objects to create unique keys and fetch clients or resources. Additionally, assignments must be boto3 client or resource objects.

Modules

Refer to the following modules for more details on configuration, implementation, and available exceptions.

boto3_client_cache.cache

Low-level API for caching boto3 clients based on their initialization parameters.

boto3_client_cache.exceptions

Custom exceptions and warning types for boto3-client-cache.

boto3_client_cache.session

High-level API which provides a subclass of boto3.session.Session that implements automatic caching for clients and resources.