mrproliu commented on code in PR #11099:
URL: https://github.com/apache/skywalking/pull/11099#discussion_r1264674121
##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/management/ui/menu/UIMenuManagementService.java:
##########
@@ -35,25 +40,29 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@Slf4j
-public class UIMenuManagementService implements Service, Runnable {
+public class UIMenuManagementService implements Service {
private static final String MENU_ID = "1";
private static final Gson GSON = new Gson();
- private static final int MENU_GET_MAX_SECOND = 3;
+ private final LoadingCache<Boolean, List<MenuItem>> menuItemCache;
private UIMenuManagementDAO menuDAO;
private ModuleManager moduleManager;
- private CompletableFuture<List<MenuItem>> menuItemFuture;
- private boolean isMenuItemsBeenFetched = false;
private MetadataQueryService metadataQueryService;
- public UIMenuManagementService(ModuleManager moduleManager) {
+ public UIMenuManagementService(ModuleManager moduleManager,
CoreModuleConfig moduleConfig) {
this.moduleManager = moduleManager;
- this.menuItemFuture = new CompletableFuture<>();
+ this.menuItemCache = CacheBuilder.newBuilder()
+ .maximumSize(1)
+ .refreshAfterWrite(moduleConfig.getUiMenuRefreshInterval(),
TimeUnit.SECONDS)
Review Comment:
The cache would be read from the database and written into the cache when
accessing the menu for the first time. After the writing is completed, a timer
starts counting, and when it reaches a certain point, the data would be
automatically rewritten.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]