ASP.NET自定义输出缓存提供程序(3)
public override object Get(string key)
{
string path =
String.Format("{0}{1}.binary", cachePath, key);
if (File.Exists(path))
{
FileStream fs = new FileStream(
path, FileMode.Open, FileAccess.Read);
BinaryFormatter formatter = new BinaryFormatter();
object result = formatter.Deserialize(fs);
fs.Close();
return result;
}
else
{
return null;
}
}
/// <summary>
/// 根据键移除缓存
/// </summary>
/// <param name="key">缓存键</param>
public override void Remove(string key)
{
string path =
String.Format("{0}{1}.binary", cachePath, key);
if (File.Exists(path))
{
File.Delete(path);
}
}
/// <summary>
/// 设置缓存
/// </summary>
/// <param name="key">缓存的键</param>
/// <param name="entry">缓存的对象</param>
相关新闻>>
- 发表评论
-
- 最新评论 进入详细评论页>>
今日头条
更多>>您可能感兴趣的文章
- .NET简谈互操作(四:基础知识之Dispose非托管内存
- JQuery+Asp.net MVC实现用户名重名查询
- .net架构的最后思考(箴言)
- 使用ASP.NET MVC3+EF+Jquery制作文字直播系统(四
- 聊聊.net程序设计——浅谈使用VS2010建模拓展(下
- Web Service学习笔记(4)
- asp.net DataTable和Dataset序列化成Json格式
- Spring MVC 3.0.5+Spring 3.0.5+MyBatis3.0.4全注
- MVC3+Entity Framework 实现投票系统(二)
- .NET设计模式:工厂方法模式(Factory Method)[1]



