update to cache flush method

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1884 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent 9f979d4fa5
commit e94b374d56

@ -66,7 +66,7 @@ Changes take effect immediately</td>
</p>
<p>
<div class=small><b>Indexing Cache Settings:</b></div>
<div class=small><b>Cache Settings:</b></div>
<form action="PerformanceQueues_p.html" method="post" enctype="multipart/form-data">
<table border="0" cellpadding="5" cellspacing="1" width="100%">
<tr valign="top" class="TableHeader">

@ -62,7 +62,6 @@ public final class plasmaWordIndexCache /*implements plasmaWordIndexInterface*/
private static final String indexArrayFileName = "indexDump1.array";
public static final int wCacheReferenceLimit = 50;
public static final long wCacheMaxAge = 1000 * 60 * 60 * 2; // milliseconds; 2 hours
public static final long wCacheMinAge = 1000; // milliseconds; 1 second
public static final long kCacheMaxAge = 1000 * 60 * 2; // milliseconds; 2 minutes
// class variables
@ -318,9 +317,9 @@ public final class plasmaWordIndexCache /*implements plasmaWordIndexInterface*/
String hash = null;
int count = hashScore.getMaxScore();
if ((count > wCacheReferenceLimit) &&
((hash = (String) hashScore.getMaxObject()) != null) &&
(System.currentTimeMillis() - longEmit(hashDate.getScore(hash)) > wCacheMinAge)) {
// flush high-score entries, but not if they are too 'young'
((hash = (String) hashScore.getMaxObject()) != null)) {
// we MUST flush high-score entries, because a loop deletes entries in cache until this condition fails
// in this cache we MUST NOT check wCacheMinAge
return hash;
}
long oldestTime = longEmit(hashDate.getMinScore());
@ -329,17 +328,13 @@ public final class plasmaWordIndexCache /*implements plasmaWordIndexInterface*/
// flush out-dated entries
return hash;
}
// not an urgent case
if (Runtime.getRuntime().freeMemory() < 10000000) {
// low-memory case
// cases with respect to memory situation
if (Runtime.getRuntime().freeMemory() < 1000000) {
// urgent low-memory case
hash = (String) hashScore.getMaxObject(); // flush high-score entries (saves RAM)
if (System.currentTimeMillis() - longEmit(hashDate.getScore(hash)) < wCacheMinAge) {
// to young, take it from the oldest entries
hash = (String) hashDate.getMinObject();
}
} else {
// not-efficient-so-far case
hash = (String) hashDate.getMinObject(); // flush oldest entries (makes indexing faster)
// not-efficient-so-far case. cleans up unnecessary cache slots
hash = (String) hashDate.getMinObject(); // flush oldest entries
}
return hash;
}

Loading…
Cancel
Save