Skip to content

Commit b7386f5

Browse files
committed
Clean cached service plan instead of force refresh
1 parent a2cbe75 commit b7386f5

File tree

1 file changed

+10
-1
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/appservice/serviceplan

1 file changed

+10
-1
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/azure/toolkit/intellij/appservice/serviceplan/ServicePlanComboBox.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.microsoft.azure.toolkit.intellij.common.AzureComboBox;
1717
import com.microsoft.azure.toolkit.intellij.common.Draft;
1818
import com.microsoft.azure.toolkit.lib.appservice.DraftServicePlan;
19+
import com.microsoft.azure.toolkit.lib.common.cache.CacheManager;
1920
import com.microsoft.azure.toolkit.lib.common.model.Region;
2021
import com.microsoft.azure.toolkit.lib.common.model.Subscription;
2122
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
@@ -28,6 +29,7 @@
2829
import java.util.ArrayList;
2930
import java.util.List;
3031
import java.util.Objects;
32+
import java.util.concurrent.ExecutionException;
3133
import java.util.function.Predicate;
3234
import java.util.stream.Collectors;
3335
import java.util.stream.Stream;
@@ -55,6 +57,13 @@ public void setSubscription(Subscription subscription) {
5557
this.clear();
5658
return;
5759
}
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+
}
5867
this.refreshItems();
5968
}
6069

@@ -112,7 +121,7 @@ protected List<? extends AppServicePlanEntity> loadItems() throws Exception {
112121
.collect(Collectors.toList()));
113122
}
114123
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)
116125
.collect(Collectors.toList());
117126
plans.addAll(remotePlans);
118127
Stream<AppServicePlanEntity> stream = plans.stream();

0 commit comments

Comments
 (0)