kezhenxu94 commented on code in PR #10544:
URL: https://github.com/apache/skywalking/pull/10544#discussion_r1139930376


##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/common/TableHelper.java:
##########
@@ -54,6 +58,16 @@ public class TableHelper {
     @Getter(lazy = true, value = AccessLevel.PRIVATE)
     private final ConfigService configService = 
moduleManager.find(CoreModule.NAME).provider().getService(ConfigService.class);
 
+    private final LoadingCache<String, Boolean> tableExistence =
+        CacheBuilder.newBuilder()
+                    .expireAfterWrite(10, TimeUnit.MINUTES)
+                    .build(new CacheLoader<>() {
+                        @Override
+                        public @NonNull Boolean load(@NonNull String 
tableName) throws Exception {
+                            return jdbcClient.tableExists(tableName);
+                        }
+                    });

Review Comment:
   > How about we have an `expireAfterRead` and do manually remove when `table 
not found` SQL exception? If possible, this could reduce more payload.
   
   Hi, `expireAfterWrite` --> `expireAfterRead` sounds reasonable to me. 
However manually invalidating the cache doesn't make any sense to me, manually 
invalidating the cache only cause the `LoadingCache` to invoke the `load` 
method and tries to fill the cache again and thus increase the load, it 
**doesn't** sounds like "hey, if there is no entry in cache, don't do 
anything", this is how a loading cache works: load in the cache first, if 
absent, load from a remote source or load through a heavy computational 
operation, by manually invalidating the cache you are requesting the heavy 
computational operations over and over again because the cache entry is 
invalidated manually.



-- 
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]

Reply via email to