- 浏览: 492422 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (329)
- [发布至博客园首页] (12)
- [随笔分类][01] .Net X (59)
- [随笔分类][20] Architecture (16)
- [随笔分类][21] Developer Logs (13)
- [网站分类]Windows 7 (1)
- [随笔分类][13] Oracle & .Net (7)
- [随笔分类][16] Love in China (14)
- [随笔分类][15] Development Tools (20)
- [随笔分类][18] Windows Phone (12)
- [随笔分类][12] Design & Pattern (17)
- [网站分类].NET新手区 (22)
- [网站分类]首页候选区 (2)
- [随笔分类][08] Windows (Server) (13)
- [随笔分类][02] CSLA.Net (3)
- [随笔分类][10] jQuery & javaScript (10)
- [随笔分类][11] SQL Server (4)
- [随笔分类][22] Enterprise Logs (3)
- [随笔分类][03] News (9)
- [随笔分类][19] Quality Assurance (2)
- [随笔分类][05] Silverlight (20)
- [随笔分类][14] Google Earth & .Net (6)
- [网站分类]非技术区 (9)
- [随笔分类][07] WWF (2)
- [随笔分类][04] SharePoint (1)
- [随笔分类][20] Analysis & Design (36)
- [随笔分类][06] WCF (5)
- [随笔分类][12] Architecture (1)
- [随笔分类][09] WPF (0)
- [随笔分类][17] VStudio & Expression (5)
最新评论
-
zhangyy130:
你好,我关于第二段的那个表视图、模型与图这三者的关系我没有看明 ...
UML模型的组成 -
guji528:
谢谢分享!
Enterprise Architect 基础应用 -
studentsky:
好文章,图文并茂!
WCF 第一个用 Visual Studio 2010 创建的WCF服务 -
chen975311486:
用哪个工具画的????
UML中对关系的描述 (二) -
frankies:
继续学习中。。
UML 交互概述图
一,下载并安装好Enterprise Library 4.1
二,新建一个Web应用程序
三,右键点击Web.Config 文件 使用 Edit Enterprise Library Configuration 可以编辑Web.Config,建立一个缓存程序块
1.可以在Cache Managers 中建立多个缓存管理器,然后设置默认使用哪个管理器
2.可以右键为管理器添加一种存储方式,如果不加就是默认的内存存储。
3.管理器的名字用来做Key,获取存储区对象
4.保存后,打开Web.config 会看到
<cachingConfiguration defaultCacheManager="Cache Manager"> <cacheManagers> <add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="Null Storage" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Cache Manager" /> <add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="Isolated Storage" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Cache Manager1" /> </cacheManagers> <backingStores> <add partitionName="IsolatedCache" encryptionProviderName="" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.IsolatedStorageBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Isolated Storage" /> <add encryptionProviderName="" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Null Storage" /> </backingStores> </cachingConfiguration>
四,添加引用
using Microsoft.Practices.EnterpriseLibrary.Caching;
using Microsoft.Practices.EnterpriseLibrary.Caching.Expirations;
五.写代码(例子我是复制菩提树下的杨过的代码)
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Microsoft.Practices.EnterpriseLibrary.Caching; using Microsoft.Practices.EnterpriseLibrary.Caching.Expirations; namespace CachingBlock { public class MyData { public string Name { set; get; } public int Age { set; get; } public string Color { set; get; } } public partial class WebForm1 : System.Web.UI.Page { const string KEYNAME = "myDateCache";//缓存的键值 ICacheManager cacheManager; protected void Page_Load(object sender, EventArgs e) { cacheManager = CacheFactory.GetCacheManager();//实例化ICachemanager } protected void btnWrite_Click(object sender, EventArgs e) { //生成要缓存的数据(实际开发中可以是从数据库查询出来的数据) List<MyData> _list = new List<MyData>{ new MyData(){ Age=1, Color="Yellow", Name="China"}, new MyData{ Age=2,Color="Black",Name="USA"} }; AbsoluteTime _ExpireTime = new AbsoluteTime(DateTime.Now.AddSeconds(30));//指定30秒后过期 cacheManager.Add(KEYNAME, _list, CacheItemPriority.Normal, null, _ExpireTime);//加入缓存 Response.Write("Cache写入完成," + DateTime.Now.ToString()); } protected void btnRead_Click(object sender, EventArgs e) { this.R1.DataSource = GetCacheData(); this.R1.DataBind(); Response.Write("Cache加载完成," + DateTime.Now.ToString()); } /// <summary> /// 获取缓存数据 /// </summary> /// <returns></returns> public List<MyData> GetCacheData() { List<MyData> _cacheData = cacheManager.GetData(KEYNAME) as List<MyData>; if (null == _cacheData)//记得一定要加此判断(因为缓存可能过期) { //如果缓存数据为空,则重新生成数据,并加入缓存(为检测效果,特地把Color与Name前加了一个"New") _cacheData = new List<MyData> { new MyData(){ Age=1, Color="New Yellow", Name="New China"}, new MyData{ Age=2,Color="New Black",Name="New USA"} }; AbsoluteTime _ExpireTime = new AbsoluteTime(DateTime.Now.AddSeconds(30));//指定30秒后过期 cacheManager.Add(KEYNAME, _cacheData, CacheItemPriority.Normal, null, _ExpireTime); } return _cacheData; } protected void btnRemove_Click(object sender, EventArgs e) { cacheManager.Remove(KEYNAME); Response.Write("Cache清空完成," + DateTime.Now.ToString()); } } }
示例源码下载:EL41Sample.rar
Enterprise Library 4.1 目录:Enterprise Library 4.1 快速使用图文笔记 目录
发表评论
-
[转] 面向对象设计原则
2009-08-02 14:23 624一、单一职责原则(S ... -
iBATIS.NET
2009-09-03 17:49 1404下载主页: http://ibatis.apache.org ... -
Castle
2009-09-06 16:23 694下载地址:http://www.castleproject.o ... -
CSLA.Net 3.0.5 版本 教学程序,代码附教学注释
2009-09-13 10:01 1293离开原来的公司后,就 ... -
Enterprise Library 4.1 Logging Block 快速使用图文笔记
2009-10-04 12:06 1618一,下载并安装好Enterprise Library ... -
Enterprise Library 4.1 Data Access Block 快速使用图文笔记
2009-10-04 17:30 1271一,下载并安装好Enterprise Library 4. ... -
Enterprise Library 4.1 Cryptography Block 快速使用图文笔记
2009-10-04 20:10 710哈希算法------ http://baike.baidu.c ... -
Enterprise Library 4.1 Security Block 快速使用图文笔记
2009-10-05 08:33 901.Net 2.0 开始,从前Security Block 一部 ... -
Enterprise Library 4.1 Application Settings 快速使用图文笔记
2009-10-05 08:41 876Application Settings 可以使我们运用企业库 ... -
Unity Application Block 1.2 图文学习笔记
2009-10-05 09:05 715此内容将会在数星期后学习 -
Enterprise Library 4.1 Policy Injection Block 快速使用图文笔记
2009-10-05 09:09 716示例源码下载:EL41Sample.rarEnterprise ... -
Enterprise Library 4.1 Instrumentation 快速使用图文笔记
2009-10-05 09:17 743示例源码下载:EL41Sample.rarEnterprise ... -
CSLA.Net 3.0.5 项目管理示例 业务基类 Project.cs
2009-10-06 09:39 1154using System; using System.Coll ... -
CSLA.Net 3.0.5 项目管理示例 业务集合基类(ProjectResources.cs,ProjectResource.cs)
2009-10-06 09:47 865using System; using System.Data ... -
CSLA.Net 3.0.5 项目管理示例 名值列表基类、只读基类、业务负责人基类
2009-10-06 10:01 718using System; using System.Da ... -
CSLA.Net 3.0.5 项目管理示例 UI ProjectEdit.aspx
2009-10-06 10:23 878<%@ Page Language="C#&q ...
相关推荐
Enterprise Library4.1中文教程,共8个模块。安全管理(Security Application Block), 缓存管理(Caching Application Block)...都一一做了介绍
This release includes: Caching Block, Cryptography Block, Data Access Block, Exception Handling Block, Logging Block, Policy Injection Block, Security Block, Validation Block, and Unity; ☆ 文件清单...
This release of Enterprise Library includes: Caching Application Block, Cryptography Application Block, Data Access Application Block, Exception Handling Application Block, Logging Application Block, ...
Microsoft Enterprise Library is a collection of reusable application blocks designed to assist software developers with common enterprise development challenges. This release includes: Caching Block,...
Enterprise Library 4.0版本包含以下应用程序块: Caching Application Block . 开发人员可以使用这个程序块在应用程序中应用缓存. 支持可插拔的缓存提供者(Provider)。 Cryptography Application Block . ...
Enterprise Library for .NET Framework 2.0 是微软发布的企业库,它...using Microsoft.Practices.EnterpriseLibrary.Caching; using Microsoft.Practices.EnterpriseLibrary.Caching.Expirations; using System; na
微软今天发布了Enterprise Library 3.0,又有新的东西可以研究了,在Enterprise Library 3.0中包含如下8个应用程序块: l Caching Application Block l Cryptography Application Block l Data Access ...
Tutorial : Enterprise Library - Using Caching Application Block
Microsoft Enterprise Library 5.0 系列(一) Caching Application Block
包含服务端: memcached-win32.server.1.2.6.0 memcached-win32.server.1.4.4 包含客户端: Enyim.Caching1.2.0.0.dll Enyim.Caching2.12.0.0.dll Memcached.ClientLibrary1.0.0 安装说明文档
A high performance caching library for Java.zip
Enyim.Caching.dll 32位 Enyim.Caching.dll 32位 Enyim.Caching.dll 32位
Enterprise Library consists of a collection of application blocks and core infrastructure. All of these are reusable software components designed to assist developers with common enterprise ...
A high performance caching library for Java 8.zip,Java 8的高性能缓存库
Section 4.1. Uniform Resource Locators Section 4.2. The Domain Name System Section 4.3. The HyperText Transfer Protocol Section 4.4. The HTTP Message Exchange Section 4.5. Hyperlinks and ...
Reactive extension for the Kingfisher image downloading and caching library.zip,翠鸟图片下载缓存库的反应式扩展
Memcached客户端Enyim.Caching