CacheDependency.GetUniqueID 方法

定義

擷取 CacheDependency 物件的唯一識別項。

public:
 virtual System::String ^ GetUniqueID();
public virtual string GetUniqueID ();
abstract member GetUniqueID : unit -> string
override this.GetUniqueID : unit -> string
Public Overridable Function GetUniqueID () As String

傳回

CacheDependency 物件的唯一識別碼。

範例

下列程式碼範例會建立名為 aggDep 的物件,其陣列中有兩 CacheDependencyAggregateCacheDependency 物件。 具現化之後 aggDep ,程式碼會呼叫 GetUniqueID 方法,為包含的相依性 aggDep 產生唯一識別碼,並將識別碼顯示到包含的頁面。 接著會使用 Insert 方法,將 aggDep 專案新增至 Cache ,做為相依性。

         ' Create two CacheDependency objects, one to a
         ' text file and the other to an XML file. 
         ' Create a CacheDependency array with these 
         ' two objects as items in the array.
          txtDep = New CacheDependency(Server.MapPath("Storage.txt"))
          xmlDep = New CacheDependency(Server.MapPath("authors.xml"))
          Dim DepArray() As CacheDependency = {txtDep, xmlDep}

          ' Create an AggregateCacheDependency object and 
          ' use the Add method to add the array to it.   
          aggDep = New AggregateCacheDependency()
          aggDep.Add(DepArray)

          ' Call the GetUniqueId method to generate
          ' an ID for each dependency in the array.
          msg1.Text = aggDep.GetUniqueId()
          
          ' Add the new data set to the cache with 
          ' dependencies on both files in the array.
          Cache.Insert("XMLDataSet", Source, aggDep)

備註

這個方法特別適用于追蹤與專案或應用程式相關聯之類別的 CacheDependency 多個實例。

識別碼是檔案相依性) 的檔案名 (組合,或是快取金鑰相依性 () 以及這個方法指派給相依性之字串的組合。 在衍生自 類別的類別中 CacheDependency ,您可以覆寫此方法,以自訂其產生唯一識別碼的方式。

適用於

另請參閱