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

本文介绍如何使用EntLib5.0的CachingApplicationBlock进行基本的缓存操作,包括设置缓存项、获取缓存项等。通过示例程序演示了创建控制台应用程序并配置缓存模块的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.参考资料及源代码下载

参考资料下载

示例程序下载

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值