我已经将ASP.NET Web API CacheOutput库用于我的web.net的asp.net项目并且它工作正常,但是我有一个POST方法的另一个控制器,我想从该控制器使我的缓存无效.
[AutoInvalidateCacheOutput]
public class EmployeeApiController : ApiController
{
[CacheOutput(ClientTimeSpan = 100, ServerTimeSpan = 100)]
public IEnumerable<DropDown> GetData()
{
//Code here
}
}
public class EmployeesController : BaseController
{
[HttpPost]
public ActionResult CreateEmployee (EmployeeEntity empInfo)
{
//Code Here
}
}
Run Code Online (Sandbox Code Playgroud)
我希望在员工控制器中添加\ update时使Employees Cache无效.
做出以下声明是否合法:
if(Cache[CACHE_KEY] == null)
{
//do something to form cache
}
else
{
//do something else that uses cache
}
Run Code Online (Sandbox Code Playgroud)
我不确定我的程序是否实际运行正常(即使它编译)并且我想知道缓存是否不存在它是否设置为null?