Caches.fanout()
The named sharded cache (one registered with shards=), looked up as caches[name] is.
Usage
Caches.fanout(name)A NullCache while it can’t be opened or is disabled, exactly as for a plain cache. That includes a directory whose layout doesn’t match the registration (LayoutMismatchError: a plain cache’s directory, or settings too small for the folder’s shard count): reported through on_open_error, remembered, and retried after retry_open_after. A folder with another shard count than the registered one is not an error: it opens with its own count, and the registry logs a WARNING (see the class docs). Its transact(retry=False, *, key=None) accepts the key= a FanoutCache needs, so caches.fanout(name).transact(key=k) runs whether the cache is on or off. Both kinds satisfy ShardedCacheLike, so code (or a test fake) can be typed against that; the return stays the union so shard_of and shards still type-check on it when it’s a FanoutCache.
Raises
KeyError-
No cache by that name is registered.
TypeError-
The cache is a plain one (use
caches[name]), or its settings are invalid. ValueError- Its settings are invalid.