using a concurrent hash map for the template cache

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5584 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent e8ae2599fd
commit e9a4182e6a

@ -78,6 +78,7 @@ import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
import de.anomic.htmlFilter.htmlFilterContentScraper; import de.anomic.htmlFilter.htmlFilterContentScraper;
@ -118,8 +119,8 @@ public final class httpdFileHandler {
Date lastModified; Date lastModified;
byte[] content; byte[] content;
} }
private static final HashMap<File, SoftReference<TemplateCacheEntry>> templateCache; private static final ConcurrentHashMap<File, SoftReference<TemplateCacheEntry>> templateCache;
private static final HashMap<File, SoftReference<Method>> templateMethodCache; private static final ConcurrentHashMap<File, SoftReference<Method>> templateMethodCache;
public static final boolean useTemplateCache; public static final boolean useTemplateCache;
@ -130,8 +131,8 @@ public final class httpdFileHandler {
static { static {
final serverSwitch<?> theSwitchboard = plasmaSwitchboard.getSwitchboard(); final serverSwitch<?> theSwitchboard = plasmaSwitchboard.getSwitchboard();
useTemplateCache = theSwitchboard.getConfig("enableTemplateCache","true").equalsIgnoreCase("true"); useTemplateCache = theSwitchboard.getConfig("enableTemplateCache","true").equalsIgnoreCase("true");
templateCache = (useTemplateCache)? new HashMap<File, SoftReference<TemplateCacheEntry>>() : new HashMap<File, SoftReference<TemplateCacheEntry>>(0); templateCache = (useTemplateCache)? new ConcurrentHashMap<File, SoftReference<TemplateCacheEntry>>() : new ConcurrentHashMap<File, SoftReference<TemplateCacheEntry>>(0);
templateMethodCache = (useTemplateCache) ? new HashMap<File, SoftReference<Method>>() : new HashMap<File, SoftReference<Method>>(0); templateMethodCache = (useTemplateCache) ? new ConcurrentHashMap<File, SoftReference<Method>>() : new ConcurrentHashMap<File, SoftReference<Method>>(0);
if (httpdFileHandler.switchboard == null) { if (httpdFileHandler.switchboard == null) {
httpdFileHandler.switchboard = theSwitchboard; httpdFileHandler.switchboard = theSwitchboard;

Loading…
Cancel
Save