private void cleanupLists ( PrefixKey key ) { // Remove expired list entries. Keep track of the last list removed. NavigableMap < PrefixKey , CacheValue < Object > > head = prefixMap . headMap ( key , true ) . descendingMap ( ) ; Iterator < Entry < PrefixKey , CacheValue < Object > > > headItr = head . entrySet ( ) . iterator ( ) ; Entry < PrefixKey , CacheValue < Object > > last = null ; while ( headItr . hasNext ( ) ) { Entry < PrefixKey , CacheValue < Object > > entry = headItr . next ( ) ; if ( isExpired ( entry . getValue ( ) ) && key . isParent ( entry . getKey ( ) ) ) { last = entry ; headItr . remove ( ) ; } } // If a list was removed, check its contained items for expiration. if ( last != null ) { SortedMap < PrefixKey , CacheValue < GoogleCloudStorageItemInfo > > prefix = getPrefixSubMap ( itemMap , last . getKey ( ) ) ; prefix . entrySet ( ) . removeIf ( entry -> isExpired ( entry . getValue ( ) ) ) ; } }
Removes expired list entries that contain the given key . If a list was removed it s contained items are checked for expiration too .