TableCacheDependency

TableCacheDependency:

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") { }    }}

Item:

using System.Web.Caching;
namespace PetShop.TableCacheDependency {    /// <summary>    /// Implementation of Item Cache Dependency for SQL Server 2000    /// </summary>    public class Item : TableDependency {
        /// <summary>        /// Call its base constructor by passing its specific configuration key        /// </summary>        public Item() : base("ItemTableDependency") { }    }}

category:

using System.Web.Caching;
namespace PetShop.TableCacheDependency {    /// <summary>    /// Implementation of Category Cache Dependency for SQL Server 2000    /// </summary>    public class Category : TableDependency {
        /// <summary>        /// Call its base constructor by passing its specific configuration key        /// </summary>        public Category() : base("CategoryTableDependency") { }    }}

posted on 2011-04-03 21:42  xingya  阅读(178)  评论(0)    收藏  举报