xunliu commented on code in PR #8297:
URL: https://github.com/apache/gravitino/pull/8297#discussion_r2315065304
##########
core/src/main/java/org/apache/gravitino/cache/CaffeineEntityCache.java:
##########
@@ -331,18 +346,66 @@ private <KEY, VALUE> Caffeine<KEY, VALUE>
newBaseBuilder(Config cacheConfig) {
}
/**
- * Invalidates the entities by the given cache key.
+ * Invalidate entities with iterative BFS algorithm.
*
* @param identifier The identifier of the entity to invalidate
*/
- private boolean invalidateEntities(NameIdentifier identifier) {
- List<EntityCacheKey> entityKeysToRemove =
-
Lists.newArrayList(cacheIndex.getValuesForKeysStartingWith(identifier.toString()));
+ private boolean invalidateEntities(
+ NameIdentifier identifier,
+ Entity.EntityType type,
+ Optional<SupportsRelationOperations.Type> relTypeOpt) {
+ Queue<EntityCacheKey> queue = new ArrayDeque<>();
- cacheData.invalidateAll(entityKeysToRemove);
- entityKeysToRemove.forEach(key -> cacheIndex.remove(key.toString()));
+ EntityCacheKey valueForExactKey;
+ if (relTypeOpt.isEmpty()) {
+ valueForExactKey =
+ cacheIndex.getValueForExactKey(EntityCacheKey.of(identifier,
type).toString());
+ } else {
+ valueForExactKey =
+ cacheIndex.getValueForExactKey(
+ EntityCacheRelationKey.of(identifier, type,
relTypeOpt.get()).toString());
+ }
Review Comment:
Fixed
--
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]