yuqi1129 commented on code in PR #12006:
URL: https://github.com/apache/gravitino/pull/12006#discussion_r3670717578


##########
core/src/main/java/org/apache/gravitino/cache/CaffeineEntityCache.java:
##########
@@ -80,33 +85,34 @@ public class CaffeineEntityCache extends BaseEntityCache {
 
   private static final Logger LOG = 
LoggerFactory.getLogger(CaffeineEntityCache.class.getName());
 
+  /**
+   * Entity types that must not be cached by this implementation.
+   *
+   * <p>{@code USER}, {@code GROUP} and {@code ROLE} are materialized with 
relation-derived data
+   * joined in at load time: a role carries its securable objects, and a 
user/group carries its role
+   * names. A mutation on the entity itself invalidates its own key through 
the write path, but this
+   * embedded data also goes stale through a mutation on a different entity. 
For example, deleting
+   * or renaming a securable object changes a role's materialized form, and 
deleting or renaming a
+   * role changes a user's/group's role names. Such a mutation touches neither 
this entity's own key
+   * nor any hierarchy ancestor of it, so neither the write-path invalidation 
nor the prefix cascade
+   * in {@link #invalidateHierarchy} would evict it; only the (now removed) 
reverse index could.
+   * Caching them would therefore serve stale authorization data.
+   */
+  private static final Set<Entity.EntityType> NON_CACHEABLE_TYPES =
+      Sets.immutableEnumSet(
+          Entity.EntityType.USER, Entity.EntityType.GROUP, 
Entity.EntityType.ROLE);

Review Comment:
   Indeed. I will move `NON_CACHEABLE_TYPES` to the right position.



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