final class KeyCache
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private class |
KeyCache.CacheEntry
Utility class to cache key entries with an expiration date.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,KeyCache.CacheEntry> |
cache
This is the main caching data structure.
|
private java.time.Clock |
clock |
private static int |
DEFAULT_MAX_CACHE_SIZE |
private static int |
DEFAULT_MAX_TTL |
static java.lang.String |
MAX_CACHE_SIZE_CONFIG
Name of the property that configures the maximum cache size.
|
static java.lang.String |
MAX_TTL_CONFIG
Name of the property that configures the maximum cache TTL.
|
private int |
maxCacheSize
This is the maximum number of entries that the key cache will hold.
|
private long |
maxTtl
This is the maximum TTL [s] that all key cache entries will have.
|
Constructor and Description |
---|
KeyCache()
Creates a new instance of this class.
|
KeyCache(java.time.Clock clock)
Creates a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
KeyEntry |
find(Name n,
int dclass)
Find the 'closest' trusted DNSKEY rrset to the given name.
|
void |
init(java.util.Properties config)
Initialize the cache.
|
private java.lang.String |
key(Name n,
int dclass) |
private KeyEntry |
lookupEntry(java.lang.String key) |
void |
store(KeyEntry ke)
Store a
KeyEntry in the cache. |
public static final java.lang.String MAX_TTL_CONFIG
public static final java.lang.String MAX_CACHE_SIZE_CONFIG
private static final int DEFAULT_MAX_TTL
private static final int DEFAULT_MAX_CACHE_SIZE
private final java.util.Map<java.lang.String,KeyCache.CacheEntry> cache
private final java.time.Clock clock
private long maxTtl
private int maxCacheSize
public KeyCache()
public KeyCache(java.time.Clock clock)
clock
- The clock to use for cache eviction.public void init(java.util.Properties config)
config
- The configuration information.public KeyEntry find(Name n, int dclass)
n
- The name to start the search.dclass
- The class this DNSKEY rrset should be in.public void store(KeyEntry ke)
KeyEntry
in the cache. The entry will be ignored if it isn't a DNSKEY rrset, if
it doesn't have the SECURE security status, or if it isn't a null-Key.ke
- The key entry to cache.private java.lang.String key(Name n, int dclass)
private KeyEntry lookupEntry(java.lang.String key)