Abyss-lord commented on code in PR #7354:
URL: https://github.com/apache/gravitino/pull/7354#discussion_r2146346144


##########
core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStore.java:
##########
@@ -184,7 +217,20 @@ public List<TagEntity> associateTagsWithMetadataObject(
   public <E extends Entity & HasIdentifier> List<E> listEntitiesByRelation(
       Type relType, NameIdentifier nameIdentifier, Entity.EntityType 
identType, boolean allFields)
       throws IOException {
-    return backend.listEntitiesByRelation(relType, nameIdentifier, identType, 
allFields);
+    return cache.withCacheLock(
+        () -> {
+          Optional<List<E>> entities = cache.getIfPresent(relType, 
nameIdentifier, identType);
+          if (entities.isPresent()) {
+            return entities.get();
+          }
+
+          List<E> backendEntities =
+              backend.listEntitiesByRelation(relType, nameIdentifier, 
identType, allFields);
+
+          cache.put(nameIdentifier, identType, relType, backendEntities);

Review Comment:
   > Also you only cache the list relations, not the list operation, what is 
your consideration?
   
   The current implementation of `list()` no longer caches the returned 
entities into the cache layer. So now, each call to `list()` simply delegates 
to the backend without tracking or caching by namespace.
   because `list()` cannot guarantee accuracy or consistency with the cache 
state, This means that some recently added or removed entities may not be 
reflected immediately in subsequent `list()` calls.
   



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