ASP.Net 读取缓存Doc 如果不存在就创建这个Doc,在并发状态下 可能会有doc文件正在被其他资源使用,或者doc已存在
我用了读写锁
但是好像并不能解决我的问题
cacheLock.EnterWriteLock();
try
{
createRes = CreateCacheDir(cachePath, filePath, filename, jsonpath, strExe) ? true : false;
System.Web.HttpContext.Current.Response.ContentType = "application/json";
System.Web.HttpContext.Current.Response.Write("创建之后" + "::" + "::" + createRes);
System.Web.HttpContext.Current.Response.End();
}
finally
{
cacheLock.ExitWriteLock();
}
//using (_Lock.Write())
//{
//}
}else {
System.Web.HttpContext.Current.Response.ContentType = "application/json";
System.Web.HttpContext.Current.Response.Write("创建之后" + "::" + "::" + createRes);
System.Web.HttpContext.Current.Response.End();
}
会不会是因为我用JMeter的问题 我设置了100个线程 1秒内启动,然后会有2个线程访问500 说是文件占用 或者 其他
但是如果我设置20个线程 5秒内打开的话 就没问题