[#BloombergLP-bdlt-CalendarCache] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlt.adoc[bdlt]::CalendarCache :relfileprefix: ../../ :mrdocs: This class implements an efficient cache of _read‐only_ `bdlt::Calendar` objects that are loaded into the cache, using a calendar loader supplied at construction, as a side‐effect of the `getCalendar` manipulator. Calendars in the cache can be invalidated, and removed from the cache via the `invalidate` and `invalidateAll` methods. In addition, calendars in the cache can be made to expire based on a timeout that may be optionally supplied at construction. The `bsl::shared_ptr<const bdlt::Calendar>` objects returned from the `getCalendar` and `lookupCalendar` methods allow for the safe removal of calendars from the cache that may still have outstanding references to them. == Synopsis Declared in `<bdlt_calendarcache.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class CalendarCache; ---- == Description This container is _exception_ _neutral_ with no guarantee of rollback: if an exception is thrown during the invocation of a method on a pre‐existing instance, the container is left in a valid state, but its value is undefined. In no event is memory leaked. This class is fully thread‐safe (see `bsldoc_glossary`). == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlt/CalendarCache/2constructor-0f.adoc[`CalendarCache`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bdlt/CalendarCache/2destructor.adoc[`~CalendarCache`] [.small]#[destructor]# | Destroy this object. | xref:BloombergLP/bdlt/CalendarCache/getCalendar.adoc[`getCalendar`] | Return a shared pointer providing non‐modifiable access to the calendar having the specified `calendarName` in this calendar cache, loading the calendar into the cache using the loader that was supplied at construction if the calendar is not already present in the cache or if the calendar has expired (i.e., per a timeout optionally supplied at construction). If the loader fails, whether in loading a calendar for the first time or in reloading a calendar that has expired, return an empty shared pointer. | xref:BloombergLP/bdlt/CalendarCache/invalidate.adoc[`invalidate`] | Invalidate the calendar having the specified `calendarName` in this calendar cache, and remove it from the cache. If a calendar having `calendarName` is not present in this cache, this method has no effect. Return the number of calendars that were invalidated. Note that a calendar that has been invalidated in the cache remains valid to all outstanding references to it, obtained via earlier calls to the `getCalendar` and `lookupCalendar` methods, until all of those references have been destroyed. | xref:BloombergLP/bdlt/CalendarCache/invalidateAll.adoc[`invalidateAll`] | Invalidate all calendars in this calendar cache, and remove them from the cache. Return the number of calendars that were invalidated. Note that a calendar that has been invalidated in the cache remains valid to all outstanding references to it, obtained via earlier calls to the `getCalendar` and `lookupCalendar` methods, until all of those references have been destroyed. | xref:BloombergLP/bdlt/CalendarCache/lookupCalendar.adoc[`lookupCalendar`] | Return a shared pointer providing non‐modifiable access to the calendar having the specified `calendarName` in this calendar cache. If the calendar having `calendarName` is not found in the cache, or if the calendar has expired (i.e., per a timeout optionally supplied at construction), return an empty shared pointer. | xref:BloombergLP/bdlt/CalendarCache/lookupLoadTime.adoc[`lookupLoadTime`] | Return the datetime, in Coordinated Universal Time (UTC), at which the calendar having the specified `calendarName` was loaded into this calendar cache. If the calendar having `calendarName` is not found in the cache, or if the calendar has expired (i.e., per a timeout optionally supplied at construction), return `Datetime()`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#