public void free ( byte [ ] array ) { int len = array . length ; synchronized ( arraysBySize ) { if ( totalSize + len > maxTotalSize ) return ; Node < ArraysBySize > node = arraysBySize . get ( len ) ; if ( node == null ) { ArraysBySize arrays = new ArraysBySize ( ) ; arrays . arrays = new TurnArray <> ( len >= 128 * 1024 ? maxBuffersBySizeAbove128KB : maxBuffersBySizeUnder128KB ) ; arrays . arrays . add ( array ) ; arrays . lastCachedTime = System . currentTimeMillis ( ) ; arraysBySize . add ( len , arrays ) ; totalSize += len ; return ; } ArraysBySize arrays = node . getElement ( ) ; arrays . lastCachedTime = System . currentTimeMillis ( ) ; if ( arrays . arrays . isFull ( ) ) return ; totalSize += len ; arrays . arrays . add ( array ) ; } }
Put an array in the cache .