Fix that `shouldUseWeakMemoryCache` code was lost during merge conflict
This commit is contained in:
parent
1d4823eb48
commit
42caecf27b
|
@ -84,6 +84,9 @@ static void * SDMemoryCacheContext = &SDMemoryCacheContext;
|
|||
// `setObject:forKey:` just call this with 0 cost. Override this is enough
|
||||
- (void)setObject:(id)obj forKey:(id)key cost:(NSUInteger)g {
|
||||
[super setObject:obj forKey:key cost:g];
|
||||
if (!self.config.shouldUseWeakMemoryCache) {
|
||||
return;
|
||||
}
|
||||
if (key && obj) {
|
||||
// Store weak cache
|
||||
LOCK(self.weakCacheLock);
|
||||
|
@ -94,6 +97,9 @@ static void * SDMemoryCacheContext = &SDMemoryCacheContext;
|
|||
|
||||
- (id)objectForKey:(id)key {
|
||||
id obj = [super objectForKey:key];
|
||||
if (!self.config.shouldUseWeakMemoryCache) {
|
||||
return obj;
|
||||
}
|
||||
if (key && !obj) {
|
||||
// Check weak cache
|
||||
LOCK(self.weakCacheLock);
|
||||
|
@ -113,6 +119,9 @@ static void * SDMemoryCacheContext = &SDMemoryCacheContext;
|
|||
|
||||
- (void)removeObjectForKey:(id)key {
|
||||
[super removeObjectForKey:key];
|
||||
if (!self.config.shouldUseWeakMemoryCache) {
|
||||
return;
|
||||
}
|
||||
if (key) {
|
||||
// Remove weak cache
|
||||
LOCK(self.weakCacheLock);
|
||||
|
@ -123,6 +132,9 @@ static void * SDMemoryCacheContext = &SDMemoryCacheContext;
|
|||
|
||||
- (void)removeAllObjects {
|
||||
[super removeAllObjects];
|
||||
if (!self.config.shouldUseWeakMemoryCache) {
|
||||
return;
|
||||
}
|
||||
// Manually remove should also remove weak cache
|
||||
LOCK(self.weakCacheLock);
|
||||
[self.weakCache removeAllObjects];
|
||||
|
|
Loading…
Reference in New Issue