Mike Schall
Mike Schall

Reputation: 5899

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 and 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"?

Upvotes: 0

Views: 679

Answers (2)

David Pokluda
David Pokluda

Reputation: 10971

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
    }
}

Upvotes: 2

PhilPursglove
PhilPursglove

Reputation: 12589

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

Upvotes: 2

Related Questions