开发者

List of cached objects (including primary/secondary location) by key in AppFabric cache

I have AppFabric installed and working great caching my ASP.Net Sessions. I have 3 W2k8 Enterprise servers as my cache hosts. I created my cache with the Secondaries=1 option. I'm trying to test the High Availability option. In order to do this, I would like to login to my website, find the cache server that has my session an开发者_StackOverflow中文版d unplug it from the network (simulating a server crash). If I can still work as a logged in user, I can prove that High Availability is working and the secondary copy of my session was promoted.

How can I see a list of the objects in the cache and where the primary/secondary objects "live"?


The get-cache Powershell command can show you your caches running in a cluster, and where their objects (and regions) are located.


Use this code to get all cache objects. Be careful though because depending on your cache size it can take a significant amount of time to dump all cache objects:

foreach (var regionName in cache.GetSystemRegions())
{
    foreach (KeyValuePair<string, object> cacheItem in cache.GetObjectsInRegion(regionName))
    {
        // TODO: process cacheItem.Key and cacheItem.Value
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜