Skip to content

Commit

Permalink
Fixed issue with transcoding multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
smadappa committed Sep 9, 2020
1 parent 369cb94 commit 6e542b3
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions evcache-core/src/main/java/com/netflix/evcache/EVCacheImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1917,20 +1917,24 @@ protected <T> EVCacheLatch set(String key, T value, Transcoder<T> tc, int timeTo
for (EVCacheClient client : clients) {
String canonicalKey = evcKey.getCanonicalKey(client.isDuetClient());
String hashKey = evcKey.getHashKey(client.isDuetClient(), client.getHashingAlgorithm(), client.shouldEncodeHashKey(), client.getMaxHashingBytes());
if (tc != null) {
cd = tc.encode(value);
} else if (_transcoder != null) {
cd = ((Transcoder<Object>) _transcoder).encode(value);
} else {
cd = client.getTranscoder().encode(value);
if(cd == null) {
if (tc != null) {
cd = tc.encode(value);
} else if (_transcoder != null) {
cd = ((Transcoder<Object>) _transcoder).encode(value);
} else {
cd = client.getTranscoder().encode(value);
}
}
if (hashKey != null) {
final EVCacheValue val = new EVCacheValue(canonicalKey, cd.getData(), cd.getFlags(), timeToLive, System.currentTimeMillis());
cd = evcacheValueTranscoder.encode(val);
final CachedData cdHashed = evcacheValueTranscoder.encode(val);
final Future<Boolean> future = client.set(hashKey, cdHashed, timeToLive, latch);
if (log.isDebugEnabled() && shouldLog()) log.debug("SET : APP " + _appName + ", Future " + future + " for hashed key : " + evcKey);
} else {
final Future<Boolean> future = client.set(canonicalKey, cd, timeToLive, latch);
if (log.isDebugEnabled() && shouldLog()) log.debug("SET : APP " + _appName + ", Future " + future + " for key : " + evcKey);
}
final Future<Boolean> future = client.set(hashKey == null ? canonicalKey : hashKey, cd, timeToLive, latch);
if (log.isDebugEnabled() && shouldLog())
log.debug("SET : APP " + _appName + ", Future " + future + " for key : " + evcKey);
}
if (event != null) {
event.setTTL(timeToLive);
Expand Down

0 comments on commit 6e542b3

Please sign in to comment.