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


##########
core/src/main/java/org/apache/gravitino/GravitinoEnv.java:
##########
@@ -427,6 +439,10 @@ private void initBaseComponents() {
   private void initGravitinoServerComponents() {
     // Initialize EntityStore
     this.entityStore = EntityStoreFactory.createEntityStore(config);
+    if (config.get(Configs.CACHE_ENABLED)) {
+      this.entityCache = CaffeineEntityCache.getInstance(config, entityStore);
+      // TODO constructs a CachedEntityStore instance with the entityStore and 
entityCache
+    }

Review Comment:
   Thanks @jerryshao for the suggestion, makes sense!
   
   I've updated the implementation to support pluggable cache via Java SPI. 
Specifically:
   - Introduced a `CacheFactory` and `CacheProvider` interface to support 
dynamic creation of EntityCache implementations;
   - Added a new configuration key `gravitino.cache.typeName` to specify the 
desired cache backend (e.g., "Caffeine");
   - When cache is **enabled**, we instantiate the appropriate `EntityCache` 
via SPI and inject it into CachedEntityStore;
   - When cache is **disabled**, we still create a `CachedEntityStore`, but 
pass null for the cache instance, so all operations fall through to the 
underlying store transparently.
   This way, downstream logic only needs to work with `EntityStore` and doesn't 
need to care whether caching is enabled or not — the behavior is internally 
consistent and clean.



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