Skip to content

Commit

Permalink
Reduce pressure on checksumCache-map
Browse files Browse the repository at this point in the history
  • Loading branch information
lassetyr committed Mar 21, 2024
1 parent 0f8d63c commit 28cfe79
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/java/no/rutebanken/anshar/data/VehicleActivities.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,11 @@ public Collection<VehicleActivityStructure> addAll(String datasetId, List<Vehicl
activity.setValidUntilTime(validUntilTime);
}

String existingChecksum = checksumCache.get(key);
String existingChecksum = null;
if (checksumCache.containsKey(key)) {
existingChecksum = checksumCache.get(key);
}

timingTracer.mark("checksumCache.get");

boolean updated;
Expand Down Expand Up @@ -370,11 +374,6 @@ public Collection<VehicleActivityStructure> addAll(String datasetId, List<Vehicl
checksumCacheTmp.put(key, currentChecksum);
} else {
outdatedCounter.incrementAndGet();

//Keeping all checksums for at least 5 minutes to avoid stale data
checksumCache.set(key, currentChecksum, 5, TimeUnit.MINUTES);
timingTracer.mark("checksumCache.set");

}

if (!isLocationValid(activity)) {invalidLocationCounter.incrementAndGet();}
Expand Down

0 comments on commit 28cfe79

Please sign in to comment.