diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h index 682ea0e..b230ce9 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.h @@ -134,6 +134,13 @@ typedef void(^MVMCoreGetImageBlock)(UIImage * _Nullable, NSData * _Nullable, BOO // Clears the page and module data. - (void)clearMFCache; +// Removes a json dictionary from the cache by pageType. +- (void)removePersistentJSONCacheForPageType:(nonnull NSString *)pageType pageJSON:(nonnull NSDictionary *)jsonDictionary; + +// Removes a json dictionary from the cache by pageType. +- (void)removePersistentModuleCacheForModule:(nonnull NSString *)moduleType moduleJSON:(nonnull NSDictionary *)jsonDictionary; + + #pragma mark - Advanced Deletion // Removes a json dictionary from the cache by pageType. Pass in the block that you want to run once the dictionary is received and which queue to run it on. Pass in if you'd like the current thread to wait. diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m index 0be8bc3..3cd5e61 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreCache.m @@ -330,7 +330,7 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt"; } if (![self shouldPersistentlyCachePage:jsonDictionary pageType:pageType]) { - [[PersistentCacheManager shared] removeForKey:pageType error:nil]; + [self removePersistentJSONCacheForPageType:pageType pageJSON:jsonDictionary]; return; } @@ -367,7 +367,7 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt"; [weakSelf.moduleCache setObject:jsonDictionary forKey:module]; if (![self shouldPersistentlyCacheModule:jsonDictionary module:module]) { - [[PersistentCacheManager shared] removeForKey:module error:nil]; + [self removePersistentModuleCacheForModule:module moduleJSON:jsonDictionary]; return; } [self addModuleToPersistentCache:jsonDictionary moduleName:module expirationDate:[self getExpirationDateForJSON:jsonDictionary]]; @@ -433,6 +433,15 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt"; }]]; } +- (void)removePersistentJSONCacheForPageType:(nonnull NSString *)pageType pageJSON:(nonnull NSDictionary *)jsonDictionary { + [[PersistentCacheManager shared] removeForKey:pageType error:nil]; +} + +- (void)removePersistentModuleCacheForModule:(nonnull NSString *)moduleType moduleJSON:(nonnull NSDictionary *)jsonDictionary { + [[PersistentCacheManager shared] removeForKey:moduleType error:nil]; +} + + #pragma mark - Advanced Deletion - (void)removeJSONForPageType:(nonnull NSString *)pageType queue:(nullable NSOperationQueue *)queue waitUntilFinished:(BOOL)waitUntilFinished completionBlock:(nullable void (^)(void))completionBlock {