public User getUser(String username) throws UserNotFoundException {
DbCacheManager cacheManager = factory.getCacheManager();
//If cache is not enabled, do a new lookup of object
if (!cacheManager.isCacheEnabled()) {
User user = new DbUser(username);
return getUser(user.getID());
}
//Cache is enabled.
CacheableInteger userIDInteger = (CacheableInteger) cacheManager.get(DbCacheManager.USER_ID_CACHE, username);
//if id wan't found in cache, load it up and put it there.
if (userIDInteger == null) {
User user = new DbUser(username);
userIDInteger = new CacheableInteger(new Integer(user.getID()));
cacheManager.add(DbCacheManager.USER_ID_CACHE, username, userIDInteger);
}
return getUser(userIDInteger.getInteger().intValue());
}