entlib5.0 学习笔记 caching application block2 简单使用示例

entlib5.0 学习笔记 caching application block 简单使用示例


1.使用示例

2.参考资料及源代码下载


1.简单使用示例

该简单示例不包含比较详细的配置信息(将在下面的笔记中),仅仅是对caching application block如何使用的入门级介绍。

1.1 在vs2008中新建一个控制台应用程序,并向其中添加一个应用程序配置文件

1.2 点击Edit Enterprise Library v5 Configuration,打开gui配置器

1.3 在entlib的gui配置器中选择blocks菜单选项,点击add caching settings,保持默认配置,保存该配置文件。

1.4 添加entlib引用

1.5 编写测试代码

using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Practices.EnterpriseLibrary.Caching; using Microsoft.Practices.EnterpriseLibrary.Caching.Expirations; namespace CacheApplicationBlockTest { class Program { static void Main(string[] args) { ICacheManager cacheManager = (CacheManager)CacheFactory.GetCacheManager(); int cachedInteger = 123; cacheManager.Add("cachedInteger", cachedInteger); Console.WriteLine("Cached the integer,the integer value is {0}", cachedInteger); int retrivedInteger = (int)cacheManager.GetData("cachedInteger"); Console.WriteLine("Get the cached integer {0}", retrivedInteger); Console.ReadLine(); } } }


2.参考资料及源代码下载

参考资料下载

示例程序下载

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值