T
- the type to be cached, typically either IPAddressString or HostNamepublic abstract static class IPAddressNetwork.HostIdentifierStringCache<T extends HostIdentifierString>
extends java.lang.Object
implements java.io.Serializable
For long-running programs or servers that handle many addresses, the benefits of using a cache are that
You choose the map of your choice to be the backing map for the cache. For example, for thread-safe access to the cache, ConcurrentHashMap is a good choice. For maps of bounded size, LinkedHashMap provides the removeEldestEntry method to override to implement LRU or other eviction mechanisms.
Constructor and Description |
---|
HostIdentifierStringCache(java.util.Map<java.lang.String,T> backingMap) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(T value)
Returns whether the given instance is in the cache.
|
T |
get(byte[] bytes) |
T |
get(IPAddress.IPVersion version,
Address.SegmentValueProvider lowerValueProvider,
Address.SegmentValueProvider upperValueProvider,
java.lang.Integer prefixLength) |
T |
get(IPAddress.IPVersion version,
Address.SegmentValueProvider lowerValueProvider,
Address.SegmentValueProvider upperValueProvider,
java.lang.Integer prefixLength,
java.lang.CharSequence zone) |
T |
get(java.lang.String key)
Gets the object for the given key.
|
java.util.Map<java.lang.String,T> |
getBackingMap() |
static Address.SegmentValueProvider |
getValueProvider(byte[] bytes) |
public HostIdentifierStringCache(java.util.Map<java.lang.String,T> backingMap)
public java.util.Map<java.lang.String,T> getBackingMap()
public boolean contains(T value)
value
- public T get(java.lang.String key)
key
- HostIdentifierException
- if the key does not correspond to an instance of type Tpublic static Address.SegmentValueProvider getValueProvider(byte[] bytes)
public T get(byte[] bytes)
public T get(IPAddress.IPVersion version, Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider, java.lang.Integer prefixLength)
public T get(IPAddress.IPVersion version, Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider, java.lang.Integer prefixLength, java.lang.CharSequence zone)