diff --git a/core/src/main/java/org/apache/gravitino/cache/EntityCacheWeigher.java b/core/src/main/java/org/apache/gravitino/cache/EntityCacheWeigher.java
index edc3ca6b9b4..f9f1212dd70 100644
--- a/core/src/main/java/org/apache/gravitino/cache/EntityCacheWeigher.java
+++ b/core/src/main/java/org/apache/gravitino/cache/EntityCacheWeigher.java
@@ -32,27 +32,34 @@
import org.slf4j.LoggerFactory;
/**
- * A {@link Weigher} implementation that calculates the weight of an entity based on its type. The
- * weight is calculated as follows:
+ * A {@link Weigher} implementation that calculates the weight of an entity based on its type. In
+ * Caffeine's weight-based eviction, higher weights make entities MORE likely to be evicted (all
+ * else being equal), as the cache prefers to retain lighter entries within the maximum weight
+ * limit.
+ *
+ *
Note: Caffeine's W-TinyLFU algorithm considers both access frequency and weight. Frequently
+ * accessed heavier entries may still be retained over infrequently accessed lighter entries.
*/
public class EntityCacheWeigher implements Weigher> {
public static final int METALAKE_WEIGHT = 0; // 0 means never evict
public static final int CATALOG_WEIGHT = 0;
- public static final int SCHEMA_WEIGHT = 500; // higher weight means it will less likely be evicted
+ public static final int SCHEMA_WEIGHT = 100; // Lower weight = higher retention priority
public static final int OTHER_WEIGHT = 200;
- public static final int TAG_WEIGHT = 100;
- public static final int POLICY_WEIGHT = 100;
+ public static final int TAG_WEIGHT = 500;
+ public static final int POLICY_WEIGHT = 500;
private static final Logger LOG = LoggerFactory.getLogger(EntityCacheWeigher.class.getName());
private static final EntityCacheWeigher INSTANCE = new EntityCacheWeigher();
private static final Map ENTITY_WEIGHTS =
diff --git a/core/src/test/java/org/apache/gravitino/cache/TestCacheConfig.java b/core/src/test/java/org/apache/gravitino/cache/TestCacheConfig.java
index f7a5724bc56..6c21b3c9c4a 100644
--- a/core/src/test/java/org/apache/gravitino/cache/TestCacheConfig.java
+++ b/core/src/test/java/org/apache/gravitino/cache/TestCacheConfig.java
@@ -53,14 +53,14 @@ void testDefaultCacheConfig() {
Assertions.assertTrue(config.get(Configs.CACHE_WEIGHER_ENABLED));
Assertions.assertEquals(10_000, config.get(Configs.CACHE_MAX_ENTRIES));
Assertions.assertEquals(3_600_000L, config.get(Configs.CACHE_EXPIRATION_TIME));
- Assertions.assertEquals(9_000_000L, EntityCacheWeigher.getMaxWeight());
+ Assertions.assertEquals(24_200_000L, EntityCacheWeigher.getMaxWeight());
Assertions.assertEquals("caffeine", config.get(Configs.CACHE_IMPLEMENTATION));
}
@Test
void testPolicyAndTagCacheWeigher() throws InterruptedException {
Caffeine