Caching is an important strategy in clients and servers alike. You could probably come up with a decision tree to help you decide what to cache. Is the data read-only? Updated infrequently? Shared by many users or processes? Not too huge?
You can use static variables to hold caches. You might have something like:
That's a lazy cache - there's nothing in it until the first client asks for one, then it stays there forever. You could also load a cache at startup. My current project has both kinds. We have mechanisms to clear the lazy loads and reload the initial loads without restarting the system, just in case something change during the day.
Other cool cache options include purging "least recently used" or oldest items to save memory, "write through" on put that lets clients put new items in cache and update the database at the same time. If you have multiple load-balanced servers you may or may not have to worry about keeping caches in synch.
Google for Java Cache. There are some commercial products and open source goodies to study. Hope that helps!
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi