我有一个用ASP.NET MVC编写的CMS。我编写了一个自定义路由处理程序,它查看传入路径并确定将其路由到何处(即自定义重定向,类别页面,产品页面等)。当前路由存储在memcached服务器的缓存中。一切都很好,直到我们在服务器上获得高负载。然后,我或者从缓存中检索错误,有时甚至是404错误。同时运行需要5-10秒的报告会导致整个服务器挂起
这不是异步完成的吗?
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
var _lock = new Object();
MvcHandler handler = null;
var path = requestContext.HttpContext.Request.Path.ToLower().RemoveOutsideSlashes();
var qs = requestContext.HttpContext.Request.QueryString;
List<Cache.RouteItem> items;
lock (_lock)
{
var cache = new CacheManager();
items = cache.Routes;
}
if (!hasPermanentRedirect(path, qs, items, ref requestContext))
{
// check for categories first
handler = checkForCategory(path, items, ref requestContext);
// check for product
if (handler == null) handler = checkForProduct(path, items, ref requestContext);
// check for webpage
if (handler == null) handler = checkForWebPage(path, items, ref requestContext);
}
if (handler != null) return handler;
return new MvcHandler(requestContext);
}
答案 0 :(得分:0)
以下是我要做的事情: