in evcache-core/src/main/java/com/netflix/evcache/EVCacheImpl.java [201:227]
EVCacheKey getEVCacheKey(final String key) {
if(key == null || key.length() == 0) throw new NullPointerException("Key cannot be null or empty");
for(int i = 0; i < key.length(); i++) {
if(Character.isWhitespace(key.charAt(i))){
throw new IllegalArgumentException("key ``" + key + "`` contains invalid character at position " + i );
}
}
final String canonicalKey;
if (this._cacheName == null) {
canonicalKey = key;
} else {
final int keyLength = _cacheName.length() + 1 + key.length();
canonicalKey = new StringBuilder(keyLength).append(_cacheName).append(':').append(key).toString();
}
if (canonicalKey.length() > this.maxKeyLength.get() && !hashKey.get() && !autoHashKeys.get()) {
final String errMsg = String.format("CanonicalKey ``%s`` is too long (maxLen = %d, keyLen = %d, canonicalKeyLen = %d)", canonicalKey, this.maxKeyLength.get(), key.length(), canonicalKey.length());
log.warn(errMsg);
throw new IllegalArgumentException(errMsg);
}
boolean shouldHashKeyAtAppLevel = hashKey.get() || (canonicalKey.length() > this.maxKeyLength.get() && autoHashKeys.get());
final EVCacheKey evcKey = new EVCacheKey(_appName, key, canonicalKey, shouldHashKeyAtAppLevel ? KeyHasher.getHashingAlgorithmFromString(hashingAlgo.get()) : null, this.shouldEncodeHashKey, this.maxDigestBytes, this.maxHashLength, this.encoderBase.get());
if (log.isDebugEnabled() && shouldLog()) log.debug("Key : " + key + "; EVCacheKey : " + evcKey);
return evcKey;
}