3. Design a complex cache that reads data from a database at startup. The data retrieval
methods should query the cache i rst, and if the requested data is not found, the bean
should query the database. If the data requested is found in the database, it should be
stored in the cache.
4. Add to exercise 3 a mechanism that deletes infrequently accessed data from the cache
and updates out‐of‐date data. Ensure that the entire life cycle of the cache is appropriately
1. Design Patterns: Elements of Reusable Object‐Oriented Software (Addison‐Wesley, 1994):
Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides.
2. Head First Design Patterns (O'Reilly, 2004): Eric Freeman, Elisabeth Robson, Bert Bates,
3. Effective Java (Addison‐Wesley, 2008): Joshua Bloch.