示例#1
0
        public static int GetCacheEntityCount()
        {
            HTTPCacheService.CheckSetup();
            Dictionary <Uri, HTTPCacheFileInfo> obj = HTTPCacheService.Library;
            int count;

            lock (obj)
            {
                count = HTTPCacheService.Library.Count;
            }
            return(count);
        }
示例#2
0
        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);
        }
示例#3
0
 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
         {
         }
     }
 }