WaveSubmittedTweetsCache cache = new WaveSubmittedTweetsCache();
if (!newTweets.isEmpty()) {
twitterWave.setLatestTweetId(newTweets.get(0).getId());
cache.purge(twitterWave.getWaveId(), twitterWave.getLatestTweetId());
} else {
String lastTweetSubmitted = cache.last(twitterWave.getWaveId());
if (!Util.isEmpty(lastTweetSubmitted) &&
lastTweetSubmitted.compareTo(twitterWave.getLatestTweetId()) > 0) {
twitterWave.setLatestTweetId(lastTweetSubmitted);
cache.purge(twitterWave.getWaveId(), lastTweetSubmitted);
}