Applications rely on in memory caching of data for faster performance. There are multiple aspects that need to be considered while enabling in memory caching of data:
- Life cycle management for the cached data – This is around the governance on when the cache gets created and when it gets destroyed.
- Avoid session object misuse – A typical pattern when some data is needed across requests is to use the HttpSession object as a store. Unfortunately, this pattern requires well orchestrated coding to ensure that the data is cleared out once it is no longer needed. Typically, this is a tedious process and results in session size bloat causing failures in session replication etc.
- Thread safe – The cache initialization has to be thread-safe and ensure that initialization does not happen more than once.
Canvas provides a simple cache management layer that relies on a XML based declaration of the caches. Canvas provides a simple means to access the cache from anywhere within the application. Every cache is associated with its data handler that is responsible for fetching data for the cache.