package buzzerproxy; import java.util.ArrayList; import java.util.HashMap; /** * CacheDeleter - beinhaltet alle Funktione zum Cachen eines Suchbegriffs und * seiner Results * * @author Sebastian Enger * @see Serialization * @since 1.1 * @version 1.1 / 2011-08-21 * @typ Class * */ public class CacheDeleter extends Thread { HashMap> cache = new HashMap>(); public CacheDeleter(HashMap> cache) { this.cache = cache; } public synchronized void cleanCache() { ArrayList value = new ArrayList(); long epoch = System.currentTimeMillis() / 1000; int count = 0; for (String key : cache.keySet()) { value = cache.get(key); ResultContainer it = value.get(count); long storetime = it.getLastChecked(); if (storetime + Constant.CACHE_VALID_THROUGH > epoch) { value.remove(count); } count++; } } @Override public void run() { cleanCache(); } } // static class CacheDeleter extends Thread {