Skip to content

Commit

Permalink
the key name should be based on a hash so as to ensure
Browse files Browse the repository at this point in the history
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 021372c
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions force-di/main/classes/di_PlatformCache.cls
Expand Up @@ -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)
Expand Down

0 comments on commit 021372c

Please sign in to comment.