Class lsst::utils::Cache¶
-
template<typename
Key, typenameValue, typenameKeyHash, typenameKeyPred>
classCache¶ Cache of most recently used values
This object stores the most recent
maxElementsvalues, wheremaxElementsis set in the constructor. Objects (of typeValue) are stored by a key (of typeKey; hence the need to provide aKeyHashandKeyPred), and the class presents a dict-like interface. Objects may be added to (add) and retrieved from (operator[]) the cache. For ease of use, an interface (operator()) is also provided that will check the cache for an existing key, and if the key is not present, generate it with a function provided by the user.- Note
ValueandKeymust be copyable.- Note
This header (
Cache.h) should generally only be included in source files, not other header files, because you probably don’t want all of theboost::multi_indexincludes in your header. We suggest you se theCacheFwd.hfile in your header instead, and hold theCacheas astd::unique_ptr.- Note
Python bindings (for pybind11) are available in
lsst/utils/python/Cache.h.