Skip to content

Commit

Permalink
chore(bom): Add caching to speed up BOM resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Cohen committed Aug 14, 2019
1 parent 687319d commit 87cee00
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import com.netflix.spinnaker.halyard.core.problem.v1.Problem;
import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
Expand All @@ -30,6 +32,9 @@
@Component
@Slf4j
public class ProfileRegistry {
Map<String, BillOfMaterials> bomCache =
new Hashtable<>(); // TODO Expire. Crazy # of ops for a single deploy

@Autowired(required = false)
GoogleProfileReader googleProfileReader;

Expand All @@ -47,7 +52,14 @@ public InputStream readProfile(String artifactName, String version, String profi
}

public BillOfMaterials readBom(String version) throws IOException {
return pickProfileReader(version).readBom(version);
BillOfMaterials bom = this.bomCache.get(version);
if (bom == null) {
bom = this.pickProfileReader(version).readBom(version);
if (bom != null) {
bomCache.put(version, bom);
}
}
return bom;
}

public Versions readVersions() throws IOException {
Expand Down

0 comments on commit 87cee00

Please sign in to comment.