Skip to content

Commit

Permalink
perf(cats): Deserialize relationships into Set vs List (#2666)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajordens authored May 29, 2018
1 parent d0fa9ff commit 348d34c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ public void putCacheResult(String sourceAgentType, Collection<String> authoritat
Map<String, Collection<String>> evictions = new HashMap<>();

for (String type : allTypes) {
final Collection<String> previousSet;
final Set<String> previousSet;
if (authoritativeTypes.contains(type)) {
previousSet = new HashSet<>(getExistingSourceIdentifiers(type, sourceAgentType));
previousSet = getExistingSourceIdentifiers(type, sourceAgentType);
} else {
previousSet = new HashSet<>();
}
Expand Down Expand Up @@ -193,7 +193,7 @@ private Collection<CacheData> buildResponse(Collection<CacheData> source) {
return Collections.unmodifiableCollection(response);
}

private Collection<String> getExistingSourceIdentifiers(String type, String sourceAgentType) {
private Set<String> getExistingSourceIdentifiers(String type, String sourceAgentType) {
CacheData all = backingStore.get(type, ALL_ID);
if (all == null) {
return new HashSet<>();
Expand All @@ -202,7 +202,7 @@ private Collection<String> getExistingSourceIdentifiers(String type, String sour
if (relationship == null) {
return new HashSet<>();
}
return relationship;
return relationship instanceof Set ? (Set<String>) relationship : new HashSet<>(relationship);
}

private void cacheDataType(String type, String sourceAgentType, Collection<CacheData> items) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public abstract class AbstractRedisCache implements WriteableCache {

protected static final TypeReference<Map<String, Object>> ATTRIBUTES = new TypeReference<Map<String, Object>>() {
};
protected static final TypeReference<List<String>> RELATIONSHIPS = new TypeReference<List<String>>() {
protected static final TypeReference<Set<String>> RELATIONSHIPS = new TypeReference<Set<String>>() {
};

private final Logger log = LoggerFactory.getLogger(getClass());
Expand Down

0 comments on commit 348d34c

Please sign in to comment.