Skip to content

Commit

Permalink
update LruMemoryCache
Browse files Browse the repository at this point in the history
  • Loading branch information
wyouflf committed Jul 26, 2014
1 parent 30c6cf9 commit 569ec6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion library/src/com/lidroid/xutils/cache/KeyExpiryMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public synchronized Long put(K key, Long expiryTimestamp) {
public synchronized boolean containsKey(Object key) {
boolean result = false;
if (super.containsKey(key)) {
if (System.currentTimeMillis() < super.get(key)) {
Long expiryTimestamp = super.get(key);
if (expiryTimestamp != null && System.currentTimeMillis() < expiryTimestamp) {
result = true;
} else {
this.remove(key);
Expand Down
11 changes: 5 additions & 6 deletions library/src/com/lidroid/xutils/cache/LruMemoryCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@ public final V get(K key) {
throw new NullPointerException("key == null");
}

// If expired, remove the entry.
if (!keyExpiryMap.containsKey(key)) {
this.remove(key);
return null;
}

V mapValue;
synchronized (this) {
// If expired, remove the entry.
if (!keyExpiryMap.containsKey(key)) {
this.remove(key);
return null;
}
mapValue = map.get(key);
if (mapValue != null) {
hitCount++;
Expand Down

0 comments on commit 569ec6c

Please sign in to comment.