From f30bdf20c5af7b1c3051a3069613d0489ebfc445 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Tue, 9 Jul 2019 17:06:29 +0530 Subject: [PATCH] removed pages and modules from cache based on server input. --- .../LoadHandling/MVMCoreLoadRequestOperation.m | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 17ad922..f92d577 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -359,6 +359,8 @@ if (!loadObject.pageDataFromCache) { loadObject.pageJSON = pageJSON; loadObject.pageType = [pageJSON string:KeyPageType]; + //Remove the pages and modules from cache + [self removeCaches:[jsonDictionary dict:@"RemoveCaches"]]; } // Sets the response info map @@ -830,6 +832,20 @@ } } ++ (void)removeCaches:(nullable NSDictionary *)cacheDictionary { + + if (cacheDictionary) { + NSArray *pagesToClear = [cacheDictionary array:@"pagesToClear"]; + NSArray *modulesToClear = [cacheDictionary array:@"modulesToClear"]; + if (modulesToClear) { + [[MVMCoreCache sharedCache] removeJSONForModules:modulesToClear]; + } + [pagesToClear enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + [[MVMCoreCache sharedCache] removeJSONForPageType:obj]; + }]; + } +} + #pragma mark - Presentation Delegate - (void)navigationController:(UINavigationController *)navigationController willDisplayViewController:(UIViewController *)viewController {