Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

renew cache update time if a cache-read hit happens

orbiter912116c5a761
diff --git a/source/de/anomic/kelondro/kelondroObjectCache.java b/source/de/anomic/kelondro/kelondroObjectCache.java
index 8cf603e21..3fd2a1ff8 100644
--- a/source/de/anomic/kelondro/kelondroObjectCache.java
+++ b/source/de/anomic/kelondro/kelondroObjectCache.java
@@ -202,7 +202,11 @@ public class kelondroObjectCache {
public Object get(String key) {
if (key == null) return null;
- Object r = cache.get(key);
+ Object r = null;
+ synchronized(cache) {
+ r = cache.get(key);
+ ages.setScore(key, intTime(System.currentTimeMillis())); // renew cache update time
+ }
flushc();
if (r == null) this.readMiss++; else this.readHit++;
return r;
@@ -237,6 +241,7 @@ public class kelondroObjectCache {
if (key == null) return 0;
synchronized(cache) {
if (hasnot.getScore(key) > 0) {
+ hasnot.setScore(key, intTime(System.currentTimeMillis())); // renew cache update time
this.hasnotHit++;
return -1;
}