SharePoint – Distributed Cache – Cache referred to does not exist
Problem:
You may find that certain functions within the farm that rely on Distributed Cache are not working. You review the SharePoint ULS logs and find errors like the following:
Unexpected Exception in SPDistributedCachePointerWrapper::InitializeDataCacheFactory for usage ‘DistributedBouncerCache’ – Exception ‘Microsoft.ApplicationServer.Caching.DataCacheException: ErrorCode:SubStatus:Cache referred to does not exist. Contact administrator or use the Cache administration tool to create a Cache.
at Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ResponseBody respBody, RequestBody reqBody)
at Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCacheProperties(RequestBody request, IClientChannel channel)
at Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName)
at Microsoft.SharePoint.DistributedCaching.SPDistributedCachePointerWrapper.InitializeDataCacheFactory()’.
Unexpected Exception in SPDistributedCachePointerWrapper::InitializeDataCacheFactory for usage ‘DistributedLogonTokenCache’ – Exception ‘Microsoft.ApplicationServer.Caching.DataCacheException: ErrorCode:SubStatus:Cache referred to does not exist. Contact administrator or use the Cache administration tool to create a Cache.
Cause:
Usually we see this when something went wrong with Distributed Cache provisioning. The cache service is up, but none of the caches got created.
However, it’s also possible that just a single cache (or a few) are missing. That’s why it’s important to check which caches you currently have and compare to a known-good.
Resolution:
You can use this PowerShell to check which caches you currently have:
Use-CacheCluster
$caches = Get-Cache | select cachename
foreach ($cache in $caches)
{$cache.CacheName}
Here’s an example output from a SharePoint 2019 farm:
Then you can use PowerShell to re-create the missing caches.
Notes:
- Each version of SharePoint has slightly different caches, so the recreation script is slightly different for each.
- If you find you are just missing a few caches, the script would have to be adjusted to only recreate the missing ones.
## PowerShell DISCLAIMER:
## This script is made available to you without any express, implied, or statutory warranty,
## not even the implied warranty of merchantability or fitness for a particular purpose,
## or the warranty of title or non-infringement.
## The entire risk of the use or the results from the use of this script remains with you
### 2019 Version ###
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
Use-CacheCluster
$farmId = $(get-spfarm).Id.ToString()
$caches =
@(
"DistributedAccessCache_",
"DistributedActivityFeedCache_",
"DistributedActivityFeedLMTCache_",
"DistributedBouncerCache_",
"DistributedDbLevelFailoverCache_",
"DistributedDefaultCache_",
"DistributedEdgeHeaderCache_",
"DistributedFileLockThrottlerCache_",
"DistributedFileStorePerformanceTraceCache_",
"DistributedHealthScoreCache_",
"DistributedLogonTokenCache_",
"DistributedResourceTallyCache_",
"DistributedSearchCache_",
"DistributedSecurityTrimmingCache_",
"DistributedServerToAppServerAccessTokenCache_",
"DistributedSharedWithUserCache_",
"DistributedSPAbsBlobCache_",
"DistributedSPCertificateValidatorCache_",
"DistributedSPOAuthTokenCache_",
"DistributedStopgapCache_",
"DistributedUnifiedAppsCache_",
"DistributedUnifiedAuditCache_",
"DistributedUnifiedGroupsCache_",
"DistributedViewStateCache_"
)
foreach ($cache in $caches)
{
New-Cache -CacheName "$cache$farmId"
}
New-Cache -CacheName "default"
#
### 2016 Version ###
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
Use-CacheCluster
$farmId = $(get-spfarm).Id.ToString()
$caches =
@(
"DistributedAccessCache_",
"DistributedActivityFeedCache_",
"DistributedActivityFeedLMTCache_",
"DistributedBouncerCache_",
"DistributedDefaultCache_",
"DistributedFileLockThrottlerCache_",
"DistributedHealthScoreCache_",
"DistributedLogonTokenCache_",
"DistributedResourceTallyCache_",
"DistributedSearchCache_",
"DistributedSecurityTrimmingCache_",
"DistributedServerToAppServerAccessTokenCache_",
"DistributedSharedWithUserCache_",
"DistributedUnifiedGroupsCache_",
"DistributedViewStateCache_"
)
foreach ($cache in $caches)
{
New-Cache -CacheName "$cache$farmId"
}
New-Cache -CacheName "default"
#
#### 2013 Version ###
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
Use-CacheCluster
$farmId = $(get-spfarm).Id.ToString()
$caches =
@(
"DistributedAccessCache_",
"DistributedActivityFeedCache_",
"DistributedActivityFeedLMTCache_",
"DistributedBouncerCache_",
"DistributedDefaultCache_",
"DistributedLogonTokenCache_",
"DistributedSearchCache_",
"DistributedSecurityTrimmingCache_",
"DistributedServerToAppServerAccessTokenCache_",
"DistributedViewStateCache_"
)
foreach ($cache in $caches)
{
New-Cache -CacheName "$cache$farmId"
}
New-Cache -CacheName "default"