I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 49a6cdbd authored by zzz's avatar zzz
Browse files

- Clear the geoip negative cache periodically

parent 2700028d
No related branches found
No related tags found
No related merge requests found
...@@ -43,6 +43,7 @@ public class GeoIP { ...@@ -43,6 +43,7 @@ public class GeoIP {
private final Set<Long> _pendingSearch; private final Set<Long> _pendingSearch;
private final Set<Long> _notFound; private final Set<Long> _notFound;
private final AtomicBoolean _lock; private final AtomicBoolean _lock;
private int _lookupRunCount;
public GeoIP(RouterContext context) { public GeoIP(RouterContext context) {
_context = context; _context = context;
...@@ -92,9 +93,14 @@ public class GeoIP { ...@@ -92,9 +93,14 @@ public class GeoIP {
} }
private class LookupJob implements Runnable { private class LookupJob implements Runnable {
private static final int CLEAR = 8;
public void run() { public void run() {
if (_lock.getAndSet(true)) if (_lock.getAndSet(true))
return; return;
// clear the negative cache every few runs, to prevent it from getting too big
if (((++_lookupRunCount) % CLEAR) == 0)
_notFound.clear();
Long[] search = _pendingSearch.toArray(new Long[_pendingSearch.size()]); Long[] search = _pendingSearch.toArray(new Long[_pendingSearch.size()]);
if (search.length <= 0) if (search.length <= 0)
return; return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment