服务端缓存HttpRuntime.Cache的使用

HttpRuntime.Cache.Insert("缓存key", "缓存content", null, DateTime.Now.AddMinutes(3), TimeSpan.Zero);//存入本地服务端

string cacheContent = string.Empty;
if (HttpRuntime.Cache["缓存key"] == null)//当缓存为空的时候执行的逻辑
{
Response.AddHeader("refresh", "1;url=路径");//刷新页面
}
else
{
cacheContent = (string)HttpRuntime.Cache["缓存key"];//根据key取值
}

但是有时候如何过是回调的方式那么就需要不断的刷新来获取新的值,也可以加上下面这段js

<script type="text/javascript">
function SX() {
location.reload();

setTimeout("SX()", 1000);

}
setTimeout("SX()", 1000);

</script>

作者:D调灬仔
出处:https://www.cnblogs.com/chj929555796/
您的推荐是我最大的动力,如果觉得这篇文章对你有帮助的话,请点个“推荐”哦,博主在此感谢!
原文地址:https://www.cnblogs.com/chj929555796/p/4733727.html