public IScript Load(FileInfo fileInfo) { try { Guid hash; var existingItem = GetCached(fileInfo, out hash); if (existingItem.HasValue) { var item = existingItem.Value; item.Accessed = DateTime.Now; return(item.Script); } if (hash == Guid.Empty) { hash = _hasher.GetHash(fileInfo); } var loaded = _loader.Load(fileInfo); var cachedItem = new CachedScriptItem { Accessed = DateTime.Now, Updated = DateTime.Now, Script = loaded, Hash = hash }; _cache[fileInfo.FullName] = cachedItem; _logger.Debug($"Inserted script into cache: {fileInfo.Name}: hash {hash.ToString()}"); return(loaded); } finally { RemoveStale(); } }
public IScript Load(FileInfo fileInfo) { try { Guid hash; var existingItem = GetCached(fileInfo, out hash); if (existingItem.HasValue) { var item = existingItem.Value; item.Accessed = DateTime.Now; return item.Script; } if (hash == Guid.Empty) { hash = _hasher.GetHash(fileInfo); } var loaded = _loader.Load(fileInfo); var cachedItem = new CachedScriptItem { Accessed = DateTime.Now, Updated = DateTime.Now, Script = loaded, Hash = hash }; _cache[fileInfo.FullName] = cachedItem; _logger.Debug($"Inserted script into cache: {fileInfo.Name}: hash {hash.ToString()}"); return loaded; } finally { RemoveStale(); } }