The approach adopted was to create a Cache class wrapped around a Map
collection. The current implementation of the Map is a HashMap ,
but if a faster collection becomes available it could be substituted without
impact. There are actually two types of cache defined to suit the various
needs of the end user.
- Total Cache
-
The total cache is a cache which needs to be refreshed, as a whole, on
a periodic basis. The intended use of this cache is to provide fast
access to a small set of data, such as lookup values. The data all must
become stale at the same time, as the cache is refreshed as a
whole.
- MRU Cache
-
The MRU Cache (Most Recently Used Cache) is a cache which has
a set of data that is larger than the cache itself. The cache operates
in what is known alternately as a Most Recently Used (MRU) or uses a
Least Recently Used (LRU) algorithm. What this means is that the most
recently requested items are kept in the cache, while the least
recently used are cached only briefly, and tend to be fetched on each
request. An MRU cache is very useful for data which it is even slightly
expensive to retrieve, and which conforms to the 80/20 rule - 20% of
the data is used 80% of the time. It is ideal if you wish to cache
large amount of data, but for performance reasons you don't want to
have a very large
Map in the memory footprint.
|