Naming:
- Increase cache size and expiration time - Add clearCache() method - Don't use EepGet or Exec for b32 - Javadoc updates
This commit is contained in:
@ -66,6 +66,10 @@ public class EepGetNamingService extends NamingService {
|
||||
|
||||
hostname = hostname.toLowerCase();
|
||||
|
||||
// If you want b32, chain with HostsTxtNamingService
|
||||
if (hostname.length() == 60 && hostname.endsWith(".b32.i2p"))
|
||||
return null;
|
||||
|
||||
// check the cache
|
||||
Destination d = getCache(hostname);
|
||||
if (d != null)
|
||||
|
@ -66,6 +66,10 @@ public class ExecNamingService extends NamingService {
|
||||
|
||||
hostname = hostname.toLowerCase();
|
||||
|
||||
// If you want b32, chain with HostsTxtNamingService
|
||||
if (hostname.length() == 60 && hostname.endsWith(".b32.i2p"))
|
||||
return null;
|
||||
|
||||
// check the cache
|
||||
Destination d = getCache(hostname);
|
||||
if (d != null)
|
||||
|
@ -27,6 +27,7 @@ class LookupDest {
|
||||
|
||||
protected LookupDest(I2PAppContext context) {}
|
||||
|
||||
/** @param key 52 chars (do not include the .b32.i2p suffix) */
|
||||
static Destination lookupBase32Hash(I2PAppContext ctx, String key) {
|
||||
byte[] h = Base32.decode(key);
|
||||
if (h == null)
|
||||
@ -44,6 +45,7 @@ class LookupDest {
|
||||
}
|
||||
****/
|
||||
|
||||
/** @param h 32 byte hash */
|
||||
static Destination lookupHash(I2PAppContext ctx, byte[] h) {
|
||||
Hash key = new Hash(h);
|
||||
Destination rv = null;
|
||||
|
@ -32,7 +32,7 @@ public abstract class NamingService {
|
||||
public static final String PROP_IMPL = "i2p.naming.impl";
|
||||
private static final String DEFAULT_IMPL = "net.i2p.client.naming.HostsTxtNamingService";
|
||||
|
||||
protected static final int CACHE_MAX_SIZE = 8;
|
||||
protected static final int CACHE_MAX_SIZE = 16;
|
||||
|
||||
|
||||
/**
|
||||
@ -107,7 +107,7 @@ public abstract class NamingService {
|
||||
* The service may override the age and/or size limit
|
||||
*/
|
||||
/** Don't know why a dest would ever change but keep this short anyway */
|
||||
protected static final long CACHE_MAX_AGE = 60*1000;
|
||||
protected static final long CACHE_MAX_AGE = 7*60*1000;
|
||||
|
||||
private class CacheEntry {
|
||||
public Destination dest;
|
||||
@ -174,4 +174,11 @@ public abstract class NamingService {
|
||||
return ce.dest;
|
||||
}
|
||||
}
|
||||
|
||||
/** @since 0.8.1 */
|
||||
public void clearCache() {
|
||||
synchronized (_cache) {
|
||||
_cache.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user