Skip to content

Commit

Permalink
fix(perf): fix performance regression due to default provider cache m…
Browse files Browse the repository at this point in the history
…etrics causing extra redis reads. (#2816)
  • Loading branch information
cfieber authored Jul 26, 2018
1 parent 217103f commit 4564248
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -142,17 +142,19 @@ public void putCacheResult(String sourceAgentType, Collection<String> authoritat

for (String type : allTypes) {
final boolean authoritative = authoritativeTypes.contains(type);
final Set<String> previousIdentifiers = getExistingSourceIdentifiers(type, sourceAgentType);
final int originalSetSize = previousIdentifiers.size();
final Set<String> previousIdentifiers = authoritative ? getExistingSourceIdentifiers(type, sourceAgentType) : Collections.emptySet();
final int originalSetSize = authoritative ? previousIdentifiers.size() : -1;
int newItems = 0;
final int cacheResultSize;
if (cacheResult.getCacheResults().containsKey(type)) {
final Collection<CacheData> cacheResultsForType = cacheResult.getCacheResults().get(type);
cacheResultSize = cacheResultsForType.size();
cacheDataType(type, sourceAgentType, cacheResultsForType);
for (CacheData data : cacheResultsForType) {
if (!previousIdentifiers.remove(data.getId())) {
newItems++;
if (authoritative) {
for (CacheData data : cacheResultsForType) {
if (!previousIdentifiers.remove(data.getId())) {
newItems++;
}
}
}
} else {

0 comments on commit 4564248

Please sign in to comment.