diff --git a/YYCache/YYMemoryCache.m b/YYCache/YYMemoryCache.m index 9042d9b..3a27ccc 100644 --- a/YYCache/YYMemoryCache.m +++ b/YYCache/YYMemoryCache.m @@ -402,8 +402,9 @@ - (id)objectForKey:(id)key { node->_time = CACurrentMediaTime(); [_lru bringNodeToHead:node]; } + id value = node ? node->_value : nil; pthread_mutex_unlock(&_lock); - return node ? node->_value : nil; + return value; } - (void)setObject:(id)object forKey:(id)key {