关于HttpRuntime.Cache的运用
存Cache方法:
HttpRuntime.Cache.Add( KeyName,//缓存名 KeyValue,//要缓存的对象 Dependencies,//依赖项 AbsoluteExpiration,//绝对过期时间 SlidingExpiration,//相对过期时间 Priority,//优先级 CacheItemRemovedCallback);//缓存过期引发事件 示例:
HttpRuntime.Cache.Add("CurrencyFundCodeCache", docs, null, DateTime.Now.AddMinutes(), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
鄙人自己写了一个示例
class Program
{
static void Main(string[] args)
{
if (HttpRuntime.Cache["arrKey"] != null)
{
MyClass myClass = HttpRuntime.Cache["myClass"] as MyClass;
}
else
{
MyClass myClass = new MyClass { ID = , Name = "张三", six = "男" };
HttpRuntime.Cache.Add("myClass", myClass, null, DateTime.Now.AddDays(), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
} Console.ReadKey(); Console.ReadKey();
}
public class MyClass
{
public int ID { get; set; }
public string Name { get; set; }
public string six { get; set; }
}
关于HttpRuntime.Cache的运用的更多相关文章
- 缓存 HttpContext.Current.Cache和HttpRuntime.Cache的区别
先看MSDN上的解释: HttpContext.Current.Cache:为当前 HTTP 请求获取Cache对象. HttpRuntime.Cache:获取当前应用程序的Cache. 我们再用. ...
- HttpContext.Current.Cache 和HttpRuntime.Cache的区别
先看MSDN上的解释: HttpContext.Current.Cache:为当前 HTTP 请求获取Cache对象. HttpRuntime.Cache:获取当前应用程序的Cac ...
- ASP.NET HttpRuntime.Cache缓存类使用总结
1.高性能文件缓存key-value存储—Redis 2.高性能文件缓存key-value存储—Memcached 备注:三篇博文结合阅读,简单理解并且使用,如果想深入学习,请多参考文章中给出的博文地 ...
- HttpRuntime.Cache的使用经验
配置文件 <appSettings> <add key="EnableCache" value="true"/> "/ ...
- HttpRuntime.Cache 失效
最近做一个报纸内容类网站,为了提高响应速度,将首页各栏目以及二级栏目中Part文献列表存储在HttpRuntime.Cache缓存中,发布后发现问题,刚插入的缓存很快就失效,本机调试没有问题. 由于H ...
- 服务端缓存HttpRuntime.Cache的使用
HttpRuntime.Cache.Insert("缓存key", "缓存content", null, DateTime.Now.AddMinutes(3), ...
- HttpRuntime.Cache被清空的DataTable
将一个DataTable存到Cache中后,另一个页面新建变量并获取,操作变量,Cache中的数据也被改动了? 页面a.aspx 初始化并赋值,输出当前缓存内DataTable内数据条数 Page_L ...
- HttpContext.Current.Cache 和 HttpRuntime.Cache 区别
原文地址:http://blog.csdn.net/avon520/article/details/4872704 .NET中Cache有两种调用方式:HttpContext.Current.Cach ...
- 分布式缓存HttpRuntime.cache应用到单点登陆中_优化登陆
以前的设计方案,是我们在数据库中放一个表,用作存储验证登陆成功的用户,并且生成用户TOKEN(令牌) 分布式缓存+集群的解决方案图: 相应的代码: DE层中配置文件: receiveTimeout=& ...
- Asp.net缓存技术(HttpRuntime.Cache)
一.缓存: 5个等级的缓存 1级是网络级缓存,缓存在浏览器,CDN以及代理服务器中 (举个例子:每个帮助页面都进行了缓存,访问一个页面的代码非常简单) 2级是由.net框架 HttpRuntime ...
随机推荐
- 【黑金原创教程】 FPGA那些事儿《概念篇》
简介一本讲述非软硬片上系统的书,另外还是低级建模的使用手册. 目录[黑金原创教程] FPGA那些事儿<概念篇>:File01 - 结构的玩笑[黑金原创教程] FPGA那些事儿<概念篇 ...
- oracle 存储过程返回结果集
好久没上来了, 难道今天工作时间稍有空闲, 研究了一下oracle存储过程返回结果集. 配合oracle临时表, 使用存储过程来返回结果集的数据读取方式可以解决海量数据表与其他表的连接问题. 在存储过 ...
- 快速解决:windows安装程序无法将windows配置为在此计算机的硬件上运行
用手工运行msoobe.ext启用配置的方法, 快速解决:windows安装程序无法将windows配置为在此计算机的硬件上运行 我自己安装碰到的是蓝色这个错误,下面这个也有网友说用安装驱动等方法 ...
- [Jenkins] 解决 Gradle 编译包含 SVG Drawable 出现异常
异常信息 java.awt.AWTError: Can't connect to X11 window server using 'localhost:10.0' as the value of th ...
- Tips-Windows 10【多桌面视窗】操作
Windows 10[多桌面视窗] 当你点击任务栏上的“task view”按键时,会在屏幕中间显示你当前正在使用的桌面,你可以点击“添加桌面”来创建一个新的桌面,在这个新的桌面你可以打开其他的应用程 ...
- I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 问题
临时解决版本进入python后只需下面命令 import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
- flask系列
1.flask基础 2.flask上下文 3.flask源码剖析--请求流程 4.数据库连接池DButils 5.Flask-Session 6.WTForms 7.Flask-SQLAlchemy ...
- python基础之小数据池、代码块、编码
一.代码块.if True: print(333) print(666) while 1: a = 1 b = 2 print(a+b) for i in '12324354': print(i) 虽 ...
- CentOS6.5之Zabbix3.2.2 Server安装、汉化及Agent安装
1.安装MySQL 1.1.安装MySQL rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm yum ...
- Elasticsearch.js 发布 —— 在Node.js和浏览器中调用Elasticsearch(1)
继PHP.Ruby.Python和Perl之后,Elasticsearch最近发布了Elasticsearch.js,Elasticsearch的JavaScript客户端库.可以在Node.js和浏 ...