Some useful PowerShell commands:
Get-Cache [-HostName] [-PortNumber] | Without any parameters, this will list information about all caches and regions on a cluster. Otherwise on a specified cache host. |
Get-CacheHost [-HostName] [-PortNumber] | Sees all of the cache services status in a cluster. If the parameters are used then of the host. |
New-Cache |
Creates a new named cache. It has a few other parameters that are optional. |
Get-CacheAllowedClientAccounts | Lists all accounts that have permission. |
Grant-CacheAllowedClientAccount -Account "DOMAINNAME\username" | Grants permission for an account. |
Stop-CacheHost |
Stops the specified cache service. The exception message that you will see when it is down: ErrorCode |
Start-CacheCluster | Starts all cache services in the cluster. |
Start-CacheHost |
Starts the specified cache service. |
Restart-CacheCluster | Restarts all cache services in the cluster. |
GUI admin tool
There is also a GUI admin tool for managing the cache service: http://mdcadmintool.codeplex.com
Coding guide
To use the cache service in the codes, we need to include Microsoft.ApplicationServer.Caching.Client and Microsoft.ApplicationServer.Caching.Core to the project's References.
Examples of how to add an object to cache using Add method, Put method or Item property:
http://msdn.microsoft.com/en-us/library/ee790846%28v=azure.10%29.aspx
A simple codes example of how to use the cache service:
DataCacheFactory factory = new DataCacheFactory(); DataCache cache = factory.GetCache("test"); string key = "key1"; string value = "value1"; cache.Put(key, value); var value = cache.Get(key);
For a thorough example that uses various features of AppFabric caching service, look at the CacheAPISample project of this example projects from Microsoft. Alternatively download the codes from here and run it as a console application.
References:
http://en.wikipedia.org/wiki/AppFabric_Caching_Service
Cache Administration with Windows PowerShell (Windows Server AppFabric Caching)
http://msdn.microsoft.com/en-us/library/ff718177%28v=azure.10%29.aspx
Managing Security (Windows Server AppFabric Caching)
http://msdn.microsoft.com/en-us/library/ff921012%28v=azure.10%29.aspx
1 comment:
Very useful blog. Keep up the good work.
Post a Comment