A cache is an area of local memory that holds a copy of frequently accessed data that is otherwise expensive to get or compute.
Examples: Database Query, disk file or data report.
Cache will keep most recently used items if you will try to add more items then max specified then the least used items will removed which are expired.
We are using org.apache.commons.collections.map.LRUMap, which removes the least used entries from a fixed sized map.
Items will expire based on a time to live period. We created a separate daemon thread for the expiration of items, timestamp the last access and in a separate thread remove the items when the time to live limit is reached. We can reduce the memory pressure for applications that have long idle time in between accessing the cached objects.