0
我有一個C#WPF應用程序。我最近發現了Microsoft企業庫緩存選項。EnterpriseLibrary CacheManager在應用程序重新啓動後失效?
我下面的代碼添加到我的應用程序:
ICacheManager oCacheManager = CacheFactory.GetCacheManager();
if (!oCacheManager.Contains("TESTING"))
{
//
// Code which populates myDictionary object
//
oCacheManager.Add("TESTING", myDictionary);
if (oCacheManager.Contains("TESTING"))
Console.WriteLine("Stored!");
}
else // below never gets hit
{
Console.WriteLine("Found It!");
CachedObjects = (Dictionary<string, object>)oCacheManager.GetData("TESTING");
}
每次應用程序運行時,它的輸出「存儲!」時間。它永遠不會輸出「找到它!」。這意味着緩存在每次應用程序關閉時都會被拋出。有沒有辦法讓它持續下去,以便隨後每次啓動它時都會找到緩存並加載它?
感謝
謝謝。我現在明白了。儘管隔離存儲基本上告訴我,我的對象太大(「內部數組無法擴展到大於Int32.MaxValue元素」),而數據庫存儲意味着要穿過網絡,從而破壞了緩存的目的。所以,我猜它不會奏效。謝謝您的幫助! – Nullqwerty 2012-03-07 15:14:47