@Component
@Scope(value="singleton")
public class InetSocketAddressCache
extends java.lang.Object
InetSocketAddressCache
caches the InetSocketAddress
for the URL tasks to speed up the
execution. Caching the InetSocketAddress
reduces the domain address resolution time there by speeding
up the execution time.Constructor and Description |
---|
InetSocketAddressCache(SystemConfig systemConfig)
Initialize the
InetSocketAddressCache based on the configuration. |
Modifier and Type | Method and Description |
---|---|
static java.net.InetSocketAddress |
createInetSocketAddress(java.lang.String key)
Callback method to get the
InetSocketAddress for host:port. |
SmartCache<java.lang.String,java.net.InetSocketAddress> |
getInetCache()
Get the
InetSocketAddress cache. |
java.net.InetSocketAddress |
getInetSocketAddress(java.lang.String host,
int port)
Get the
InetSocketAddress for host and port. |
void |
invalidate(java.lang.String key)
Remove the key from cache.
|
void |
setInetCache(SmartCache<java.lang.String,java.net.InetSocketAddress> inetCache)
Set the
InetSocketAddress cache. |
@Autowired public InetSocketAddressCache(SystemConfig systemConfig)
InetSocketAddressCache
based on the configuration.systemConfig
- the configuration parameters for cachepublic static java.net.InetSocketAddress createInetSocketAddress(java.lang.String key)
InetSocketAddress
for host:port.key
- host and port in "host:port" formatInetSocketAddress
corresponding to host and portpublic java.net.InetSocketAddress getInetSocketAddress(java.lang.String host, int port)
InetSocketAddress
for host and port.host
- the request hostport
- the request portInetSocketAddress
corresponding to host and portpublic void invalidate(java.lang.String key)
key
- the key to be removedpublic SmartCache<java.lang.String,java.net.InetSocketAddress> getInetCache()
InetSocketAddress
cache.InetSocketAddress
Cachepublic void setInetCache(SmartCache<java.lang.String,java.net.InetSocketAddress> inetCache)
InetSocketAddress
cache.inetCache
- the inetCache to set