@@ -284,10 +284,6 @@ private void InitNew(int chunkNumber)
284284 try
285285 {
286286 _memoryChunk = Chunk . CreateNew ( _filename , chunkNumber , _chunkManager , _chunkConfig , true ) ;
287- if ( _logger . IsDebugEnabled )
288- {
289- _logger . DebugFormat ( "Cached new chunk {0} to memory." , this ) ;
290- }
291287 }
292288 catch ( OutOfMemoryException )
293289 {
@@ -403,10 +399,6 @@ private void InitOngoing<T>(Func<byte[], T> readRecordFunc) where T : ILogRecord
403399 try
404400 {
405401 _memoryChunk = Chunk . FromOngoingFile < T > ( _filename , _chunkManager , _chunkConfig , readRecordFunc , true ) ;
406- if ( _logger . IsDebugEnabled )
407- {
408- _logger . DebugFormat ( "Cached ongoing chunk {0} to memory." , this ) ;
409- }
410402 }
411403 catch ( OutOfMemoryException )
412404 {
@@ -454,10 +446,6 @@ public bool TryCacheInMemory(bool shouldCacheNextChunk)
454446 return false ;
455447 }
456448 _memoryChunk = Chunk . FromCompletedFile ( _filename , _chunkManager , _chunkConfig , true ) ;
457- if ( _logger . IsDebugEnabled )
458- {
459- _logger . DebugFormat ( "Cached completed chunk {0} to memory." , this ) ;
460- }
461449 if ( shouldCacheNextChunk )
462450 {
463451 Task . Factory . StartNew ( ( ) => _chunkManager . TryCacheNextChunk ( this ) ) ;
@@ -490,10 +478,6 @@ public bool UnCacheFromMemory()
490478 var memoryChunk = _memoryChunk ;
491479 _memoryChunk = null ;
492480 memoryChunk . Dispose ( ) ;
493- if ( _logger . IsDebugEnabled )
494- {
495- _logger . DebugFormat ( "Uncached completed chunk {0} from memory." , this ) ;
496- }
497481 return true ;
498482 }
499483 catch ( Exception ex )
@@ -503,7 +487,7 @@ public bool UnCacheFromMemory()
503487 }
504488 }
505489 }
506- public T TryReadAt < T > ( long dataPosition , Func < byte [ ] , T > readRecordFunc ) where T : class , ILogRecord
490+ public T TryReadAt < T > ( long dataPosition , Func < byte [ ] , T > readRecordFunc , bool autoCache = true ) where T : class , ILogRecord
507491 {
508492 if ( _isDestroying )
509493 {
@@ -512,8 +496,6 @@ public T TryReadAt<T>(long dataPosition, Func<byte[], T> readRecordFunc) where T
512496
513497 _lastActiveTime = DateTime . Now ;
514498
515- _chunkManager . TryCacheNextChunk ( this ) ;
516-
517499 if ( ! _isMemoryChunk )
518500 {
519501 if ( _cacheItems != null )
@@ -544,7 +526,7 @@ public T TryReadAt<T>(long dataPosition, Func<byte[], T> readRecordFunc) where T
544526 }
545527 }
546528
547- if ( ! _isMemoryChunk && _isCompleted && Interlocked . CompareExchange ( ref _cachingChunk , 1 , 0 ) == 0 )
529+ if ( autoCache && ! _isMemoryChunk && _isCompleted && Interlocked . CompareExchange ( ref _cachingChunk , 1 , 0 ) == 0 )
548530 {
549531 Task . Factory . StartNew ( ( ) => TryCacheInMemory ( true ) ) ;
550532 }
@@ -1229,9 +1211,8 @@ private void PrintReadStatus()
12291211 var cacheReadThroughput = cacheItemReadCount - _previousCacheReadCount ;
12301212 _previousCacheReadCount = cacheItemReadCount ;
12311213
1232- _logger . DebugFormat ( "Read status: chunk: {0}, currentTime: {1}, fileRead: {2}/s, unmanagedRead: {3}/s, cacheRead: {4}/s" ,
1233- this ,
1234- DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss.fff" ) ,
1214+ _logger . DebugFormat ( "Read status: chunkNum: #{0}, fileRead: {1}/s, unmanagedRead: {2}/s, cacheRead: {3}/s" ,
1215+ ChunkHeader . ChunkNumber ,
12351216 fileReadThroughput ,
12361217 unmanagedReadThroughput ,
12371218 cacheReadThroughput ) ;
0 commit comments