From f30bdf20c5af7b1c3051a3069613d0489ebfc445 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Tue, 9 Jul 2019 17:06:29 +0530 Subject: [PATCH 1/2] 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 { From 4c5770f21cfc1c1ba2caa03372dd206f4f4e8cb6 Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Tue, 9 Jul 2019 18:22:30 +0530 Subject: [PATCH 2/2] review comment fix --- MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index f92d577..db9d151 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -359,10 +359,11 @@ if (!loadObject.pageDataFromCache) { loadObject.pageJSON = pageJSON; loadObject.pageType = [pageJSON string:KeyPageType]; - //Remove the pages and modules from cache - [self removeCaches:[jsonDictionary dict:@"RemoveCaches"]]; } + //Remove the pages and modules from cache + [self removeCaches:[jsonDictionary dict:@"RemoveCaches"]]; + // Sets the response info map loadObject.responseInfoMap = [jsonDictionary dict:KeyResponseInfo];