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); |