Indhumathi27 commented on a change in pull request #3580: [CARBONDATA-3665] 
Support TimeBased Cache expiration using Guava Cache
URL: https://github.com/apache/carbondata/pull/3580#discussion_r369374454
 
 

 ##########
 File path: 
core/src/main/java/org/apache/carbondata/core/cache/CarbonLRUCache.java
 ##########
 @@ -95,9 +98,17 @@ public CarbonLRUCache(String propertyName, String 
defaultPropertyName) {
    * initialize lru cache
    */
   private void initCache() {
+    // get duration for cache expiration if configured
+    long duration = 
CarbonCommonConstants.CARBON_LRU_CACHE_EXPIRATION_DURATION_IN_MINUTES_DEFAULT;
+    String timeBasedExpiration = CarbonProperties.getInstance()
+        
.getProperty(CarbonCommonConstants.CARBON_LRU_CACHE_EXPIRATION_DURATION_IN_MINUTES);
+    if (null != timeBasedExpiration) {
+      duration = Long.parseLong(timeBasedExpiration);
+    }
+    // initialise guava cache with time based expiration
     lruCacheMap =
-        new LinkedHashMap<String, 
Cacheable>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE, 1.0f,
-            true);
+        
CacheBuilder.newBuilder().initialCapacity(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE)
+            .expireAfterWrite(duration, TimeUnit.MINUTES).build();
 
 Review comment:
   Size-based eviction can be supported later if needed

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to