Özel Durum İşlemeye Genel Bakış (Windows Server AppFabric Önbelleğe Alma)
Windows Server AppFabric'in önbelleğe alma API'si, hata oluştuğunda .NET özel durumları oluşturur. Bu konuda temel hata giderme kavramları incelenir ve bir örnek verilir.
DataCacheException Sınıfı
AppFabric önbelleğe alma yöntemlerine özgü hatalar için genel bir DataCacheException nesnesi oluşturulur. DataCacheException nesnesinde özel durumun nedenini tanılamanıza yardımcı olabilecek dört özellik bulunur.
DataCacheException özelliği | Açıklama |
---|---|
Hatayı açıklayan dize. |
|
DataCacheErrorCode sınıfındaki hata kodu sabitine karşılık gelen tamsayı değeri. |
|
DataCacheErrorSubStatus sınıfındaki alt durum sabitine karşılık gelen tamsayı değeri. |
|
Geçerli özel duruma neden olan özel durum örneği. Bu değer null olabilir. |
Zaman aşımı gibi bazı hatalar önbellek istemcisi yöntemi nedeniyle oluşabilir. Uygulama kodunuzun bu genel özel durumların üstesinden gelecek şekilde hazırlanması gerekir. Daha fazla bilgi için bkz. Genel Özel Durumlar (Windows Server AppFabric Önbelleğe Alma).
Not
Bazı hatalar özel durum oluşturmaz. Örneğin, Get yöntemi anahtar bulunamazsa null değeri döndürür. Diğer yöntemler başarıyı veya başarısızlığı göstermek için Boole değerleri döndürebilir. Belirli yöntemler hakkında daha fazla bilgi için Windows Server AppFabric Sınıf Kitaplığı belgelerindeki Microsoft.ApplicationServer.Caching ad alanına bakın.
Örnek
Aşağıdaki örnek myCache
adındaki bir DataCache içine strObject
adında bir dize nesnesi yerleştirmeye çalışır. Aşırı yüklenmiş Put yöntemi nesnenin önbellek bölgesini belirtmek için kullanılır. Bu bölge henüz önbellek içinde yoksa, RegionDoesNotExist hata koduyla bir DataCacheException nesnesi oluşturulur. Bu örnekte, bu hata bölge oluşturularak ve yerleştirme işlemi yeniden denenerek giderilir.
Dim strKey As String = "key0"
Dim strObject As String = "Source String"
Try
' Put a string object into the cache region, "Region1"
myCache.Put(strKey, strObject, "Region1")
Catch cacheError As DataCacheException
' Look at the ErrorCode property to see if the Region is missing
If (cacheError.ErrorCode = DataCacheErrorCode.RegionDoesNotExist) Then
' Create the Region and retry the Put call
myCache.CreateRegion("Region1")
myCache.Put(strKey, strObject, "Region1")
End If
End Try
string strKey = "key0";
string strObject = "Source String";
try
{
// Put a string object into the cache region, "Region1"
myCache.Put(strKey, strObject, "Region1");
}
catch (DataCacheException cacheError)
{
// Look at the ErrorCode property to see if the Region is missing
if (cacheError.ErrorCode == DataCacheErrorCode.RegionDoesNotExist)
{
// Create the Region and retry the Put call
myCache.CreateRegion("Region1");
myCache.Put(strKey, strObject, "Region1");
}
}
Ayrıca bkz.
Kavramlar
Genel Özel Durumlar (Windows Server AppFabric Önbelleğe Alma)
Önbellek İstemcisi Zaman Aşımlarını Yapılandırma (Windows Server AppFabric Önbelleğe Alma)
2011-12-05