Skip to content
Permalink
Browse files

the key name should be based on a hash so as to ensure

that the string used in the key is consistently under 50 charachers.

THis is important because the platform cache key cannot be greater than 50
characters.  String concatenation of SObject and class name can easily exceed
this 50 character limit; especially considering includsion of namespaces
  • Loading branch information...
ImJohnMDaniel committed Feb 25, 2019
1 parent 3e7fddb commit 021372cb6efa61ae96b6c16c10b6220eb8502ab0
Showing with 3 additions and 8 deletions.
  1. +3 −8 force-di/main/classes/di_PlatformCache.cls
@@ -84,20 +84,15 @@ public with sharing class di_PlatformCache
getCacheKeyIndexMap().get(workingDeveloperName).put( binding.bindingObject, new Set<String>() );
}

getCacheKeyIndexMap().get(workingDeveloperName).get( binding.bindingObject).add(getKeyName(binding));
getCacheKeyIndexMap().get(workingDeveloperName).get(binding.bindingObject).add(getKeyName(binding));

pushCacheKeyIndexMapToCache();
}

private String constructKeyName( Schema.SObjectType bindingSObjectType, String developerName )
{
if ( bindingSObjectType != null ) {
return bindingSObjectType.getDescribe().getName().toLowerCase().left(19) + 'P'
+ developerName.toLowerCase().trim().replaceAll('_', 'D').replaceAll('\\.','DT').left(30);
}
else {
return developerName.toLowerCase().trim().replaceAll('_', 'D').replaceAll('\\.','DT').left(50);
}
return ( ( bindingSObjectType != null ) ? bindingSObjectType.getDescribe().getName().toLowerCase() : '' )
+ developerName.toLowerCase().trim().hashCode();
}

private String getKeyName( String developerName, Schema.SObjectType bindingSObjectType)

0 comments on commit 021372c

Please sign in to comment.
You can’t perform that action at this time.