/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/util/AndroidTimeoutCache.java
ViewVC logotype

Diff of /android/TrainInfo/src/dk/thoerup/traininfo/util/AndroidTimeoutCache.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1026 by torben, Fri Oct 2 19:01:53 2009 UTC revision 1027 by torben, Wed Sep 8 06:03:45 2010 UTC
# Line 23  public class AndroidTimeoutCache<K,V> { Line 23  public class AndroidTimeoutCache<K,V> {
23                  this.timeout = timeout;                  this.timeout = timeout;
24          }          }
25                    
26            public void purgeOldEntries() {
27                    
28                    long now = android.os.SystemClock.elapsedRealtime();
29                    
30                    for (K key : cache.keySet()) {
31                            CacheItem<V> item = cache.get(key);
32                            if ( (item.lastupdate+timeout) < now) { //item too old
33                                    cache.remove(key);
34                            }
35                    }
36            }
37            
38          public void put(K k, V v) {          public void put(K k, V v) {
39                  CacheItem<V> item= new CacheItem<V>(v);                  CacheItem<V> item= new CacheItem<V>(v);
40                  cache.put(k, item);                  cache.put(k, item);

Legend:
Removed from v.1026  
changed lines
  Added in v.1027

  ViewVC Help
Powered by ViewVC 1.1.20