-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into platform-n-organisation-search
- Loading branch information
Showing
47 changed files
with
7,404 additions
and
463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
indexer/src/main/java/au/org/aodn/esindexer/service/FIFOCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package au.org.aodn.esindexer.service; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
/** | ||
* A simple FIFO cache to store a few records to improve querying speed | ||
* @param <K> | ||
* @param <V> | ||
*/ | ||
public class FIFOCache<K, V> { | ||
|
||
private final Map<K, V> cache; | ||
|
||
public FIFOCache(int maxSize) { | ||
this.cache = new LinkedHashMap<>(maxSize + 1, 1.0f, false) { | ||
@Override | ||
protected boolean removeEldestEntry(Map.Entry<K, V> eldest) { | ||
return size() > maxSize; | ||
} | ||
}; | ||
} | ||
|
||
public V get(K key) { | ||
return cache.get(key); | ||
} | ||
|
||
public void put(K key, V value) { | ||
cache.put(key, value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.