public final void removeExpired ( ) { mapLock . lock ( ) ; Iterator < Entry < String , TimestampedCacheEntry < DOReader > > > entries = cacheMap . entrySet ( ) . iterator ( ) ; if ( entries . hasNext ( ) ) { long now = System . currentTimeMillis ( ) ; while ( entries . hasNext ( ) ) { Entry < String , TimestampedCacheEntry < DOReader > > entry = entries . next ( ) ; TimestampedCacheEntry < DOReader > e = entry . getValue ( ) ; long age = e . ageAt ( now ) ; if ( age > ( maxSeconds * 1000 ) ) { entries . remove ( ) ; String pid = entry . getKey ( ) ; LOG . debug ( "removing entry {} after {} milliseconds" , pid , age ) ; } } } mapLock . unlock ( ) ; }
remove expired entries from the cache