private void cleanup ( ) { CacheEntry oldest = null ; _count = 0 ; // Cleanup obsolete entries and find the oldest for ( Map . Entry < String , CacheEntry > e : _cache . entrySet ( ) ) { String key = e . getKey ( ) ; CacheEntry entry = e . getValue ( ) ; // Remove obsolete entry if ( entry . isExpired ( ) ) { _cache . remove ( key ) ; } // Count the remaining entry else { _count ++ ; if ( oldest == null || oldest . getExpiration ( ) > entry . getExpiration ( ) ) oldest = entry ; } } // Remove the oldest if cache size exceeded maximum if ( _count > _maxSize && oldest != null ) { _cache . remove ( oldest . getKey ( ) ) ; _count -- ; } }
Clears component state .