Fixing Distributed Cache Service issues in SharePoint Server 2013

New to SharePoint Server 2013 is the Distributed Cache Service which helps in caching items in SharePoint so that your SharePoint site loads items more quickly. I had issues with a SharePoint Server 2013 test VM where the User Profile Services was not working correctly. From checking the ULS logs it turned out that the User Profile Services could not access the Distributed Cache and in the SharePoint Health Report, the Distributed Cache was not initializing properly. The following is what you can do to fix the Distributed Cache Service.

The first thing to do is to get into a PowerShell Console as a Administrator with the SharePoint Plugin loaded. Once you get that sorted, run the following command to Remove the Distributed Cache Service.

Remove-SPDistributedCacheServiceInstance

This will remove the Distributed Cache Service from SharePoint. Next run the following command.

Add-SPDistributedCacheServiceInstance

This will re-add the Distributed Cache Service and by then you should now have a fresh Distributed Cache Service running. If possible I would reboot the SharePoint Server in order for everything to start up fresh. After this is done, run the following commands in PowerShell as a Administrator with the SharePoint Plugin to make sure the Distributed Cache Service is running properly.

Get-Cache
Get-CacheClusterHealth

The Distributed Cache Service is very important in SharePoint Server 2013. If there are problems with this service, you will have a lot of strange issues come up in your SharePoint site. For my issue, I think this was due to my VM having very low memory as when I first installed SharePoint Server 2013 in my test VM, it only had 1GB of RAM. When the Distributed Cache Service tried to use the left over memory, it probably was not much to work with. So ensure that your SharePoint Server has enough memory for the services to run!