internal static void Recycle(FileReadStream stream) { try { var key = stream.Name; lock (streams) { CacheItem ignore; if (!streams.TryGetValue(key, out ignore) || Object.Equals(ignore.stream, stream)) { logger.DebugFormat("Recycling {0}", key); stream.Seek(0, SeekOrigin.Begin); var removed = streams.AddAndPop(key, new CacheItem(stream)); if (removed != null) { removed.stream.Kill(); } return; } } } catch (Exception) { // no op } stream.Kill(); }
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(); }
public CacheItem(FileReadStream stream) { this.stream = stream; insertionPoint = DateTime.UtcNow; }
public CacheItem(FileReadStream stream) { Stream = stream; }