Skip to content

Commit

Permalink
Rename isCacheValid to isCacheExpired (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
talarian1 authored Mar 9, 2023
1 parent 2016dca commit 1df63df
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main/java/com/jfrog/ide/idea/ui/LocalComponentsTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;

/**
* @author yahavi
Expand All @@ -39,7 +40,7 @@ public class LocalComponentsTree extends ComponentsTree {
private static final String SHOW_IN_PROJECT_DESCRIPTOR = "Show direct dependency in project descriptor";
private static final String NO_ISSUES = "Your project was scanned and we didn't find any security issues.";
private static final String SCANNING = "Scanning...";
private static final long VALID_CACHE_TIME = 7 * 24 * 60 * 60 * 1000; // 7 days
private static final long EXPIRED_CACHE_TIME = TimeUnit.DAYS.toMillis(7); // week

private final ScanCache cache;

Expand Down Expand Up @@ -205,11 +206,11 @@ private void setNodesFromCache() {
}

public boolean isCacheEmpty() {
return cache.getScanCacheObject() == null || !isCacheValid();
return cache.getScanCacheObject() == null || isCacheExpired();
}

private boolean isCacheValid() {
return System.currentTimeMillis() - cache.getScanCacheObject().getScanTimestamp() < VALID_CACHE_TIME;
private boolean isCacheExpired() {
return System.currentTimeMillis() - cache.getScanCacheObject().getScanTimestamp() >= EXPIRED_CACHE_TIME;
}

/**
Expand Down

0 comments on commit 1df63df

Please sign in to comment.