Beispiel #1
0
 public static void BeginClear()
 {
     if (HTTPCacheService.InClearThread)
     {
         return;
     }
     HTTPCacheService.InClearThread = true;
     HTTPCacheService.SetupCacheFolder();
     new Thread(new ParameterizedThreadStart(HTTPCacheService.ClearImpl)).Start();
 }
Beispiel #2
0
 internal static void CheckSetup()
 {
     try
     {
         HTTPCacheService.SetupCacheFolder();
         HTTPCacheService.LoadLibrary();
     }
     catch
     {
     }
 }
Beispiel #3
0
 public static void BeginMaintainence(HTTPCacheMaintananceParams maintananceParam)
 {
     if (maintananceParam == null)
     {
         throw new ArgumentNullException("maintananceParams == null");
     }
     if (HTTPCacheService.InMaintainenceThread)
     {
         return;
     }
     HTTPCacheService.InMaintainenceThread = true;
     HTTPCacheService.SetupCacheFolder();
     new Thread(delegate(object param)
     {
         try
         {
             Dictionary <Uri, HTTPCacheFileInfo> obj = HTTPCacheService.Library;
             lock (obj)
             {
                 DateTime t      = DateTime.UtcNow - maintananceParam.DeleteOlder;
                 List <Uri> list = new List <Uri>();
                 foreach (KeyValuePair <Uri, HTTPCacheFileInfo> current in HTTPCacheService.Library)
                 {
                     if (current.Value.LastAccess < t && HTTPCacheService.DeleteEntity(current.Key, false))
                     {
                         list.Add(current.Key);
                     }
                 }
                 for (int i = 0; i < list.Count; i++)
                 {
                     HTTPCacheService.Library.Remove(list[i]);
                 }
                 list.Clear();
                 ulong num = HTTPCacheService.GetCacheSize();
                 if (num > maintananceParam.MaxCacheSize)
                 {
                     List <HTTPCacheFileInfo> list2 = new List <HTTPCacheFileInfo>(HTTPCacheService.library.Count);
                     foreach (KeyValuePair <Uri, HTTPCacheFileInfo> current2 in HTTPCacheService.library)
                     {
                         list2.Add(current2.Value);
                     }
                     list2.Sort();
                     int num2 = 0;
                     while (num >= maintananceParam.MaxCacheSize && num2 < list2.Count)
                     {
                         try
                         {
                             HTTPCacheFileInfo hTTPCacheFileInfo = list2[num2];
                             ulong num3 = (ulong)((long)hTTPCacheFileInfo.BodyLength);
                             HTTPCacheService.DeleteEntity(hTTPCacheFileInfo.Uri, true);
                             num -= num3;
                         }
                         catch
                         {
                         }
                         finally
                         {
                             num2++;
                         }
                     }
                 }
             }
         }
         finally
         {
             HTTPCacheService.SaveLibrary();
             HTTPCacheService.InMaintainenceThread = false;
         }
     }).Start();
 }