Since SharePoint 2013, the New-SPConfigurationDatabase and Connect-SPConfigurationDatabase cmdlets have a parameter called “SkipRegisterAsDistributedCacheHost”. When this switch parameter is specified during the creation of a new farm or when a server is added to an existing farm, the local server will not have the Distributed Cache. With the arrival of SharePoint 2016, we also got the MinRole feature. This feature enables you to designate the local server to be a “DistributedCache” server. How to do this, is explained in one of my previous posts where I provide a script to create a farm and to join a farm. I was wondering what happens when you use the DistributedCache server role together with the -SkipRegisterAsDistributedCacheHost switch.
Best way of finding this out is to try it. I did, and found out that the server in fact was a DistributedCache host after I joined it to the farm. So, it ignores the switch completely.
But what with the other roles? How about Custom? And Search? To see how this is handled, I fired up ILSpy and started digging in the code.
In the Microsoft.SharePoint.DistributedCaching.Utilities.SPDistributedCacheServiceInstance class, a method ShouldRegisterAsDistributedCacheHost exists and this is called somewhere during the execution of one of the above 2 cmdlets.
internal static bool ShouldRegisterAsDistributedCacheHost(bool skipRegisterAsDistributedCacheHost, SPServerRole? serverRole)
return serverRole == SPServerRole.DistributedCache || serverRole == SPServerRole.SingleServerFarm || serverRole == SPServerRole.WebFrontEndWithDistributedCache || ((serverRole == SPServerRole.Custom || !serverRole.HasValue) && !skipRegisterAsDistributedCacheHost);
This method contains a test which illustrates how the decision is made if a server should be a DistributedCache host or not.
If the ServerRole parameter is DistributedCache, SingleServerFarm or WebFrontEndWithDistributedCache, the presence of the SkipRegisterAsDistributedCacheHost doesn’t matter. The server will be a Distributed Cache host. Period.
If the ServerRole parameter is not specified, “Custom” or we don’t have the MinRole feature enabled, the SkipRegisterAsDistributedCacheHost is taken into account and used in the decision.