xunliu commented on code in PR #8297:
URL: https://github.com/apache/gravitino/pull/8297#discussion_r2313882917


##########
core/src/main/java/org/apache/gravitino/cache/CaffeineEntityCache.java:
##########
@@ -194,6 +207,7 @@ public void clear() {
     withLock(
         () -> {
           cacheData.invalidateAll();
+          reverseIndex = new ReverseIndexCache();
           cacheIndex = new ConcurrentRadixTree<>(new 
DefaultCharArrayNodeFactory());

Review Comment:
   ```
   // Reinitialization: O(1) time complexity
   reverseIndex = new ConcurrentRadixTree<EntityCacheKey>(new 
DefaultCharSequenceNodeFactory());
   
   // Iterative deletion: O(n) time complexity, requires traversing all nodes
   for (CharSequence key : reverseIndex.getKeysStartingWith("")) {
        reverseIndex.remove(key); // Each removal operation has overhead
   }
   ```



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