*) httpdFileHandler templateCache can now be disabled

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@708 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 20 years ago
parent 2cb084d426
commit a6a8af0f04

@ -74,6 +74,7 @@
package de.anomic.http; package de.anomic.http;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
@ -97,6 +98,7 @@ import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverClassLoader; import de.anomic.server.serverClassLoader;
import de.anomic.server.serverCodings; import de.anomic.server.serverCodings;
import de.anomic.server.serverCore; import de.anomic.server.serverCore;
@ -126,6 +128,12 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
*/ */
private static final HashMap templateCache = new HashMap(); private static final HashMap templateCache = new HashMap();
public static boolean useTemplateCache = false;
static {
useTemplateCache = plasmaSwitchboard.getSwitchboard().getConfig("enableTemplateCache","true").equalsIgnoreCase("true");
}
public httpdFileHandler(serverSwitch switchboard) { public httpdFileHandler(serverSwitch switchboard) {
this.switchboard = switchboard; this.switchboard = switchboard;
@ -474,6 +482,7 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
try { try {
// do fileCaching here // do fileCaching here
byte[] templateContent = null; byte[] templateContent = null;
if (useTemplateCache) {
long fileSize = localizedFile.length(); long fileSize = localizedFile.length();
if (fileSize <= 512*1024) { if (fileSize <= 512*1024) {
SoftReference ref = (SoftReference) templateCache.get(localizedFile); SoftReference ref = (SoftReference) templateCache.get(localizedFile);
@ -501,7 +510,10 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
fis = new ByteArrayInputStream(templateContent); fis = new ByteArrayInputStream(templateContent);
templateContent = null; templateContent = null;
} else { } else {
fis = new FileInputStream(localizedFile); fis = new BufferedInputStream(new FileInputStream(localizedFile));
}
} else {
fis = new BufferedInputStream(new FileInputStream(localizedFile));
} }
o = new ByteArrayOutputStream(); o = new ByteArrayOutputStream();

@ -518,3 +518,5 @@ crawler.MaxIdleThreads = 7
crawler.MinIdleThreads = 5 crawler.MinIdleThreads = 5
useYacyReferer = true useYacyReferer = true
enableTemplateCache = true
Loading…
Cancel
Save