缓存补充:
来源:互联网 发布:剑三成男捏脸详细数据 编辑:程序博客网 时间:2024/05/02 04:34
petshop的缓存中还涉及到一个命名空间TableCacheDependency
该命名空间下有如下类:
Category.cs
Item.cs
Product.cs
TableDependency.cs
即我们要对Category,Item,Product 三个表进行缓存依赖。
首先看类TableDependency
using System.Web.Caching;
using System.Configuration;
namespace PetShop.TableCacheDependency {
/// <summary>
/// This is the base class for SQL2KCacheDependency implementation that encapsulates common
/// algorithm to retrieve database and table names from configuration file and create
/// the necessary AggregateCacheDependency object
/// </summary>
public abstract class TableDependency : PetShop.ICacheDependency.IPetShopCacheDependency {
// This is the separator that's used in web.config
protected char[] configurationSeparator = new char[] { ',' };
protected AggregateCacheDependency dependency = new AggregateCacheDependency();
/// <summary>
/// The constructor retrieves all related configuration and add CacheDependency object accordingly
/// </summary>
/// <param name="configKey">Configuration key for specific derived class implementation</param>
protected TableDependency(string configKey) {
string dbName = ConfigurationManager.AppSettings["CacheDatabaseName"];
string tableConfig = ConfigurationManager.AppSettings[configKey];
string[] tables = tableConfig.Split(configurationSeparator);
foreach (string tableName in tables)
dependency.Add(new SqlCacheDependency(dbName, tableName));
}
public AggregateCacheDependency GetDependency() {
return dependency;
}
}
}
具体类Product
--------------------
using System.Web.Caching;
namespace PetShop.TableCacheDependency {
/// <summary>
/// Implementation of Product Cache Dependency for SQL Server 2000
/// </summary>
public class Product : TableDependency {
/// <summary>
/// Call its base constructor by passing its specific configuration key
/// </summary>
public Product() : base("ProductTableDependency") { }
}
}
对应的web.config文件有:
<!-- Cache dependency options. Possible values: PetShop.TableCacheDependency for SQL Server and keep empty for ORACLE -->
<add key="CacheDependencyAssembly" value="PetShop.TableCacheDependency"/>
<!-- CacheDatabaseName should match the name under caching section, when using TableCacheDependency -->
<add key="CacheDatabaseName" value="MSPetShop4"/>
<!-- *TableDependency lists table dependency for each instance separated by comma -->
<add key="CategoryTableDependency" value="Category"/>
<add key="ProductTableDependency" value="Product,Category"/>
<add key="ItemTableDependency" value="Product,Category,Item"/>
- 缓存补充:
- 缓存补充
- 缓存(补充)
- Smarty缓存补充
- nginx之缓存补充
- ASP.NET 缓存(补充)
- squid+apache缓存优化补充
- 补充关于iBatis的缓存使用
- smarty变量调节器补充,缓存的应用
- 缓存以及javascript高级的补充
- mybatis补充教程之三:缓存(cache)的使用
- 补充
- 补充
- 补充
- 补充
- 补充
- 补充
- 补充
- 调教lenovo的多媒体键
- qtnode上关于qt4 with visual stdio的消息
- 调教xine和蓝牙
- 你可能不知道的Java基础知识(一)
- 启动EXA
- 缓存补充:
- 给BroadCom安装驱动
- 从Fedora转向Kbuntu
- [乌龙事件]让xine支持x264
- STL中的find函数
- 新秀迅雷更厉害
- Configure file like format of ini and read data from ini file or write data to ini file
- flex解析json字符串
- 解决crul_init模块