I agree with Eddie, and just had a similar problem only with many values, not two. I wanted a Java ConcurrentHashMap to hold a cache XML of documents being fetched from a web service, and I needed to record various pieces of information alongside the XML to support the cache's eviction strategies (eg, Least Recently Used, Least Frequently Used).
The solution was just to define a class of object that holds those items. I used a private nested class inside of my Cache class, something like this:
private static class CacheEntry
{
private String uri; // Key
private String fetched_xml; // The XML document (main value)
private long put_time;
private long expires_time;
private long size;
private long hits;
private long last_used_time;
}
The ConcurrentHashMap was keyed on the URI and looked like this:
private final Map<String, CacheEntry> cache;
[...]
cache = new ConcurrentHashMap<String, CacheEntry>(100, 0.75f, 3);
This code adds a new XML document to the cache:
CacheEntry value = new CacheEntry();
value.fetched_xml(fetched_xml);
value.uri = uri;
value.put_time = System.currentTimeMillis();
value.expires_time = representation.getExpirationDate().getTime();
value.size = bytes_fetched;
value.hits = 0;
value.last_used_time = 0;
cache.put(uri, value);
Edit: Should you need to Map a key to a List of n Objects in Java, you can put those objects in a java.util.collections.ArrayList and use the ArrayList as the Map value.