public static int GetCacheEntityCount() { HTTPCacheService.CheckSetup(); Dictionary <Uri, HTTPCacheFileInfo> obj = HTTPCacheService.Library; int count; lock (obj) { count = HTTPCacheService.Library.Count; } return(count); }
public static ulong GetCacheSize() { HTTPCacheService.CheckSetup(); ulong num = 0uL; Dictionary <Uri, HTTPCacheFileInfo> obj = HTTPCacheService.Library; lock (obj) { foreach (KeyValuePair <Uri, HTTPCacheFileInfo> current in HTTPCacheService.Library) { if (current.Value.BodyLength > 0) { num += (ulong)((long)current.Value.BodyLength); } } } return(num); }
private static void DeleteUnusedFiles() { HTTPCacheService.CheckSetup(); string[] files = Directory.GetFiles(HTTPCacheService.CacheFolder); for (int i = 0; i < files.Length; i++) { try { string fileName = Path.GetFileName(files[i]); Uri uriFromFileName = HTTPCacheService.GetUriFromFileName(fileName); Dictionary <Uri, HTTPCacheFileInfo> obj = HTTPCacheService.Library; lock (obj) { if (!HTTPCacheService.Library.ContainsKey(uriFromFileName)) { File.Delete(files[i]); } } } catch { } } }