在controller方法前加入 [ResponseCache(Duration =20)]即可实现缓存 ,这个例子显示缓存20秒,
[ResponseCache(Duration =20)]
[Route("[controller]")]
public class GetPatientTop10Controller : Controller
{
[HttpGet(Name = "GetPatientByTop")]
public IEnumerable<PatientModel> Get(string DispensingDate)
{
return MyDB.Patient.GetPatientListtop10(DispensingDate).AsEnumerable<PatientModel>();
}
}