DatastoreCacheManager

class lsst.daf.butler.DatastoreCacheManager(config: Union[str, DatastoreCacheManagerConfig], universe: DimensionUniverse)

Bases: lsst.daf.butler.AbstractDatastoreCacheManager

A class for managing caching in a Datastore using local files.

Parameters:
config : str or DatastoreCacheManagerConfig

Configuration to control caching.

universe : DimensionUniverse

Set of all known dimensions, used to expand and validate any used in lookup keys.

Methods Summary

find_in_cache(ref, extension) Look for a dataset in the cache and return its location.
move_to_cache(uri, ref) Move a file to the cache.
should_be_cached(entity, DatasetType, …) Indicate whether the entity should be added to the cache.

Methods Documentation

find_in_cache(ref: DatasetRef, extension: str) → Optional[ButlerURI]

Look for a dataset in the cache and return its location.

Parameters:
ref : DatasetRef

Dataset to locate in the cache.

extension : str

File extension expected.

Returns:
uri : ButlerURI or None

The URI to the cached file, or None if the file has not been cached.

move_to_cache(uri: ButlerURI, ref: DatasetRef) → Optional[ButlerURI]

Move a file to the cache.

Move the given file into the cache, using the supplied DatasetRef for naming. A call is made to should_be_cached() and if the DatasetRef should not be accepted None will be returned.

Parameters:
uri : ButlerURI

Location of the file to be relocated to the cache. Will be moved.

ref : DatasetRef

Ref associated with this file. Will be used to determine the name of the file within the cache.

Returns:
new : ButlerURI or None

URI to the file within the cache, or None if the dataset was not accepted by the cache.

should_be_cached(entity: Union[DatasetRef, DatasetType, StorageClass]) → bool

Indicate whether the entity should be added to the cache.

This is relevant when reading or writing.

Parameters:
entity : StorageClass or DatasetType or DatasetRef

Thing to test against the configuration. The name property is used to determine a match. A DatasetType will first check its name, before checking its StorageClass. If there are no matches the default will be returned.

Returns:
should_cache : bool

Returns True if the dataset should be cached; False otherwise.