最近在做項目的時候
step
Codeusing System;
using System
using Microsoft
/// <summary>
///CacheItemDependency 的摘要說明
/// </summary>public class CacheItemDependency : ICacheItemExpiration
{
//依賴緩存項鍵 private readonly string dependencyCacheKey;
//依賴緩存項值 private System
/// 初始化依賴緩存項
/// </summary>
/// <param name=
public CacheItemDependency(string cacheKey)
{
dependencyCacheKey = cacheKey; ICacheManager cacheManager = CacheFactory
lastCount = Int
if (cacheManager != null)
{
if (cacheManager
{
object o = cacheManager
if (o != null)
{
this
}
lastCount = (int)cacheManager
}
else
{
cacheManager
}
}
}
#endregion #region Properties public string DependencyCacheKey
{
get
{
return dependencyCacheKey;
}
}
public System
{
get
{ r
eturn lastCount;
}
}
#endregion #region ICacheItemExpiration Members public bool HasExpired()
{
ICacheManager cacheManager = CacheFactory
if (cacheManager == null)
{
return true;
}
System
if (currentCount != lastCount)
{ return true; }
else
{
return false;
}
}
public void Notify()
{ }
public void Initialize(CacheItem owningCacheItem) { }
#endregion}
using System;
using System
using Microsoft
///
///CacheItemDependency 的摘要說明
///
public class CacheItemDependency : ICacheItemExpiration
{
//依賴緩存項鍵
private readonly string dependencyCacheKey;
//依賴緩存項值
private System
#region Constructor
///
/// 初始化依賴緩存項
///
/// 依賴緩存項的鍵
public CacheItemDependency(string cacheKey)
{
dependencyCacheKey = cacheKey;
ICacheManager cacheManager = CacheFactory
lastCount = Int
if (cacheManager != null)
{
if (cacheManager
{
object o = cacheManager
if (o != null)
{
this
}
lastCount = (int)cacheManager
}
else
{
cacheManager
}
}
}
#endregion
#region Properties
public string DependencyCacheKey
{
get { return dependencyCacheKey; }
}
public System
{
get { return lastCount; }
}
#endregion
#region ICacheItemExpiration Members
public bool HasExpired()
{
ICacheManager cacheManager = CacheFactory
if (cacheManager == null)
{
return true;
}
System
if (currentCount != lastCount)
{
return true;
}
else
{
return false;
}
}
public void Notify()
{
}
public void Initialize(CacheItem owningCacheItem)
{
}
#endregion
}
step
Codeusing System;using System
/// <summary>///DataAccessUtil 的摘要說明
/// </summary>public class DataAccessUtil
{
public DataAccessUtil()
{ // //TODO: 在此處添加構造函數邏輯 //
}
/// <summary> /// 更新所有以cacheKeys中元素為key的緩存項
/// </summary> /// <param name=
</param> public static void UpdateCacheDependency(string[] cacheKeys)
{
ICacheManager cacheManager = CacheFactory
foreach (string cacheKey in cacheKeys)
{
if (cacheManager != null && cacheManager
{
int lastCount = (int)cacheManager
}
else
{
lastCount = Int
} // 這一句的作用在於更新以cacheKey為key的緩存項
}
}
}
}
using System;
using System
using Microsoft
///
///DataAccessUtil 的摘要說明
///
public class DataAccessUtil
{
public DataAccessUtil()
{
//
//TODO: 在此處添加構造函數邏輯
//
}
///
/// 更新所有以cacheKeys中元素為key的緩存項
///
/// 緩存項的key的數組
public static void UpdateCacheDependency(string[] cacheKeys)
{
ICacheManager cacheManager = CacheFactory
foreach (string cacheKey in cacheKeys)
{
if (cacheManager != null && cacheManager
{
int lastCount = (int)cacheManager
if (lastCount < Int
{
lastCount++;
}
else
{
lastCount = Int
}
// 這一句的作用在於更新以cacheKey為key的緩存項
cacheManager
}
}
}
}
step
Codeusing System;
using System
using System
using System
using System
using System
using Microsoft
public partial class Test : System
{
protected void Page_Load(object sender
{
if (!IsPostBack)
{
ICacheManager cacheManager = CacheFactory
cacheManager
this
}
} protected void Button
{
ICacheManager cacheManager = CacheFactory
DataAccessUtil
if (cacheManager
{
cacheManager
} this
}
}
From:http://tw.wingwit.com/Article/program/net/201311/13594.html