public void setCacheSize ( int cacheSize ) { this . cacheSize = cacheSize ; long toDelete = map . size ( ) - this . cacheSize ; if ( toDelete <= 0 ) { return ; } List < Integer > keys = new ArrayList <> ( map . keySet ( ) ) ; Collections . reverse ( keys ) ; for ( Integer id : keys ) { P page = map . remove ( id ) ; file . writePage ( page ) ; } }
Sets the maximum size of this cache .