|
16 | 16 | import com.microsoft.azure.toolkit.intellij.common.AzureComboBox; |
17 | 17 | import com.microsoft.azure.toolkit.intellij.common.Draft; |
18 | 18 | import com.microsoft.azure.toolkit.lib.appservice.DraftServicePlan; |
| 19 | +import com.microsoft.azure.toolkit.lib.common.cache.CacheManager; |
19 | 20 | import com.microsoft.azure.toolkit.lib.common.model.Region; |
20 | 21 | import com.microsoft.azure.toolkit.lib.common.model.Subscription; |
21 | 22 | import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation; |
|
28 | 29 | import java.util.ArrayList; |
29 | 30 | import java.util.List; |
30 | 31 | import java.util.Objects; |
| 32 | +import java.util.concurrent.ExecutionException; |
31 | 33 | import java.util.function.Predicate; |
32 | 34 | import java.util.stream.Collectors; |
33 | 35 | import java.util.stream.Stream; |
@@ -55,6 +57,13 @@ public void setSubscription(Subscription subscription) { |
55 | 57 | this.clear(); |
56 | 58 | return; |
57 | 59 | } |
| 60 | + // Clean up app service plan cache when switch subscription |
| 61 | + // todo: leverage event hub to update resource cache automatically |
| 62 | + try { |
| 63 | + CacheManager.evictCache("appservcie/{}/plans", subscription.getId()); |
| 64 | + } catch (ExecutionException e) { |
| 65 | + // swallow exception while clean up cache |
| 66 | + } |
58 | 67 | this.refreshItems(); |
59 | 68 | } |
60 | 69 |
|
@@ -112,7 +121,7 @@ protected List<? extends AppServicePlanEntity> loadItems() throws Exception { |
112 | 121 | .collect(Collectors.toList())); |
113 | 122 | } |
114 | 123 | final List<AppServicePlanEntity> remotePlans = Azure.az(AzureAppService.class) |
115 | | - .subscription(subscription.getId()).appServicePlans(true).stream().map(IAppServicePlan::entity) |
| 124 | + .subscription(subscription.getId()).appServicePlans().stream().map(IAppServicePlan::entity) |
116 | 125 | .collect(Collectors.toList()); |
117 | 126 | plans.addAll(remotePlans); |
118 | 127 | Stream<AppServicePlanEntity> stream = plans.stream(); |
|
0 commit comments