I started to use Windows Server AppFabric for its distributed caching feature and I wanted to take a note of the useful PowerShell commands to manage the service configuration and administration. When I write this blog post, Microsoft AppFabric 1.1 for Windows Server is available. I installed the caching service and caching management features firstly. Then, I configured it properly. See Configure AppFabric page for more information on configuration.
First of all, import necessary modules:
Import-Module DistributedCacheConfiguration Import-Module DistributedCacheAdministration
You can view the commands with Get-Command Cmdlet. For example, we can see all commands which are available for DistributedCacheAdministration with the following one line of code.
Get-Command -Module DistributedCacheAdministration
Use-CacheCluster command sets the context of your PowerShell session to a particular cache cluster. Note that you must run this command before using any other Cache Administration commands in PowerShell.
Get-CacheHost command lists all cache host services that are members of the cache cluster.
Your cache host is running as a windows service and you can retrieve the status of your caching host with Get-CacheHost command. It will output a result which is similar to following:
My service is up and running but if the status indicates that the service is down, you can start it with the following command:
Start-CacheHost -HostName TugberkWin08R2 -CachePort 22233
You should be able to see your service running after this:
Get-CacheClusterInfo command from configuration module returns the cache cluster information, including details on its initialization status and its size. The following one line of code shows a sample usage.
Get-CacheClusterInfo -Provider XML -ConnectionString \\TUGBERKWIN08R2\Caching
More information on this command: http://msdn.microsoft.com/en-us/library/ff631076(v=ws.10).aspx
That’s it for now.
- Microsoft AppFabric 1.1 for Windows
- ASP.NET MVC Output Caching with Windows AppFabric Cache
- C# & VB.Net / C# ile AppFabric Cache Yönetimi (in Turkish)