예제 #1
0
 internal static void Recycle(FileReadStream stream)
 {
     try
     {
         var key = stream.Name;
         lock (streams)
         {
             CacheItem ignore;
             if (!streams.TryGetValue(key, out ignore) ||
                 Equals(ignore.Stream, stream))
             {
                 logger.DebugFormat("Recycling {0}", key);
                 stream.Seek(0, SeekOrigin.Begin);
                 var removed = streams.AddAndPop(key, new CacheItem(stream));
                 removed?.Stream.Kill();
                 return;
             }
         }
     }
     catch (Exception)
     {
         // no op
     }
     stream.Kill();
 }
예제 #2
0
 public CacheItem(FileReadStream stream)
 {
     Stream = stream;
 }