0

I am using simple data caching in c# .NET without dependencies

and

I don't clear the cache anywhere. But when I delete a directory,

cache is cleared completely. Why ???

List<Software> Softwares=new List<Software>();
string cacheKey ="Software_List"

if(HttpContext.Current.Cache.[cacheKey]==null)
{
Softwares=Software.GetSoftwares();
HttpContext.Current.Cache.Insert(cacheKey,Softwares,null,DateTime.Now.AddMinutes(300)TimeSpan.Zero)
}
else
{
Softwares=HttpContext.Current.Cache.[cacheKey] as List<Software> ;
shiva
  • 1
  • 3
  • The answers are correct, so far as they go. The exception is if the directory was (further) under the `App_Data` folder. But since you didn't provide any information on where this directory was, or show any code, it's tricky to provide any further help if the given answers don't match your situation. – Damien_The_Unbeliever Jun 15 '13 at 07:22

3 Answers3

0

Because deleting a directory causes the application to be restarted.

Khanh TO
  • 48,509
  • 13
  • 99
  • 115
0

If your directory is under your Web folder, deleting it causes file change notification, which resets your app pool, which obviously kills all caches.

Ilia G
  • 10,043
  • 2
  • 40
  • 59
0

when you Create or delete directory on virtual directory, the application pool is recycle. permission issue check link

Community
  • 1
  • 1
MANISHDAN LANGA
  • 2,227
  • 6
  • 29
  • 43