class NegativeLookupCache extends Object
Caches failed lookup attempts to prevent repeated queries to unavailable or malicious peers. Implements time-based expiration and configurable failure thresholds to balance between cache effectiveness and resource usage.
Uses LRU eviction policy and periodic cleanup to maintain cache size. Provides DOS protection by rate-limiting repeated failed lookups for the same targets within configurable time windows.
Thread-safe implementation with atomic counters and scheduled cleanup operations for reliable concurrent access in multi-threaded environments.
| Modifier and Type | Field and Description |
|---|---|
(package private) static int |
MAX_FAILS |
| Constructor and Description |
|---|
NegativeLookupCache(RouterContext context) |
| Modifier and Type | Method and Description |
|---|---|
void |
cache(Hash h)
Negative cache the hash until the next clean time.
|
void |
clear() |
void |
failPermanently(Destination dest)
Negative cache the hash until restart,
but cache the destination.
|
Destination |
getBadDest(Hash h)
Get an unsupported but cached Destination
|
boolean |
isCached(Hash h) |
void |
lookupFailed(Hash h) |
void |
stop()
Stops the timer.
|
static final int MAX_FAILS
public NegativeLookupCache(RouterContext context)
public void cache(Hash h)
public void clear()
public void failPermanently(Destination dest)
public Destination getBadDest(Hash h)
public boolean isCached(Hash h)
public void lookupFailed(Hash h)
public void stop()