CacheDependency.HasChanged Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a value indicating whether the CacheDependency object has changed.
public:
property bool HasChanged { bool get(); };
public bool HasChanged { get; }
member this.HasChanged : bool
Public ReadOnly Property HasChanged As Boolean
Property Value
true
if the CacheDependency object has changed; otherwise, false
. The default is false
.
Examples
The following code example demonstrates using the HasChanged property to determine whether a CacheDependency changed since the previous request for an item in the Cache. The dt
value passed in the start
parameter is set to DateTime.Now.
// Insert the cache item.
CacheDependency dep = new CacheDependency(fileName, dt);
cache.Insert("key", "value", dep);
// Check whether CacheDependency.HasChanged is true.
if (dep.HasChanged)
Response.Write("<p>The dependency has changed.");
else Response.Write("<p>The dependency has not changed.");
' Insert the cache item.
Dim dep As New CacheDependency(fileName, dt)
myCache.Insert("key", "value", dep)
' Check whether CacheDependency.HasChanged is true.
If dep.HasChanged Then
Response.Write("<p>The dependency has changed.")
Else
Response.Write("<p>The dependency has not changed.")
End If
Remarks
You can add an item to an ASP.NET application's Cache with a CacheDependency. When the CacheDependency changes, the item added to the Cache is invalidated and removed from the cache. You can use this property to determine whether a CacheDependency has changed, and recreate the item in the Cache if that has occurred.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기