package generell; import java.io.IOException; import java.io.Serializable; 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 implements Serializable { private static final long serialVersionUID = 1L; HashMap> cache = new HashMap>(); /** Cache Writer/Reader*/ private Serialization ser; public CacheDeleter(HashMap> cache) throws IOException { this.cache = cache; ser = new Serialization( Constant.CACHEFILE ); } public synchronized void cleanCache( HashMap> cache ) { ArrayList value = new ArrayList(); long epoch = System.currentTimeMillis() / 1000; int count = 0; for (String key : cache.keySet()) { value = this.cache.get(key); ResultContainer it = value.get(count); long storetime = it.getLastChecked(); if (storetime + Constant.CACHE_VALID_TIME > epoch) { value.remove(count); } count++; } ser.writeCache(cache); } } // static class CacheDeleter extends Thread {