I suggest that you use the ASP.NET Application State to keep the DataChache Factory object.
You can write a helper class to get the Data Cache Factory object. Something like (never tested):
public class DataCacheHelper
{
public DataCacheHelper()
{
DataCacheFactory factory = new DataCacheFactory();
HttpContext.Current.Application.Lock();
HttpContext.Current.Application["dcf"] = factory;
HttpContext.Current.Application.Unock();
}
public DataCacheFactory GetFactory()
{
var factory = HttpContext.Current.Application["dcf"];
if (factory == null)
{
factory = new DataCacheFactory();
HttpContext.Current.Application.Lock();
HttpContext.Current.Application["dcf"] = factory;
HttpContext.Current.Application.Unock();
}
return factory;
}
}
Or, if you are using ASP.NET MVC - you can create a base Controller class, which has GetCacheFactory method (which exactly what the helper method do), and have all your Controllers inherit this base instead the framework one. Same could be achieved for Web Forms.