BloombergLP::bdlt::CalendarCache

Efficient cache of read-only bdlt::Calendar objects.

Synopsis

Declared in <bdlt_calendarcache.h>

class CalendarCache;

Description

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.

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

NameDescription
CalendarCache [constructor]Constructors
~CalendarCache [destructor]Destroy this object.
getCalendar Return a shared pointer to the named calendar, loading it if needed.
invalidate Invalidate and remove the named calendar from this cache.
invalidateAll Invalidate and remove all calendars from this cache.
lookupCalendar Return a shared pointer to the calendar named calendarName.
lookupLoadTime Return the UTC datetime when the named calendar was loaded.