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