This is an automated email from the ASF dual-hosted git repository.

morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new 7464b58ea18 branch-3.1: [improvement] (metadata cache) use expire 
after access strategy on meta cache #50757 (#52768)
7464b58ea18 is described below

commit 7464b58ea18e5835399ae01db324b24eb1ac9196
Author: Mingyu Chen (Rayner) <morning...@163.com>
AuthorDate: Sat Jul 5 20:25:26 2025 +0800

    branch-3.1: [improvement] (metadata cache) use expire after access strategy 
on meta cache #50757 (#52768)
    
    bp #50757
    
    Co-authored-by: wlong <869372...@qq.com>
    Co-authored-by: wanglong16 <wanglon...@xiaomi.com>
---
 .../src/main/java/org/apache/doris/common/Config.java  | 17 +++++++++++------
 .../java/org/apache/doris/common/CacheFactory.java     | 10 +++++-----
 .../org/apache/doris/datasource/ExternalCatalog.java   |  4 ++--
 .../org/apache/doris/datasource/ExternalDatabase.java  |  4 ++--
 .../apache/doris/datasource/ExternalMetaCacheMgr.java  |  5 +++--
 .../apache/doris/datasource/ExternalRowCountCache.java |  4 ++--
 .../apache/doris/datasource/ExternalSchemaCache.java   |  4 ++--
 .../doris/datasource/hive/HiveMetaStoreCache.java      | 10 +++++-----
 .../hudi/source/HudiCachedFsViewProcessor.java         |  4 ++--
 .../hudi/source/HudiCachedMetaClientProcessor.java     |  4 ++--
 .../hudi/source/HudiCachedPartitionProcessor.java      |  4 ++--
 .../doris/datasource/iceberg/IcebergMetadataCache.java | 12 ++++++------
 .../datasource/maxcompute/MaxComputeMetadataCache.java |  2 +-
 .../apache/doris/datasource/metacache/MetaCache.java   |  6 +++---
 .../doris/datasource/paimon/PaimonMetadataCache.java   |  4 ++--
 .../main/java/org/apache/doris/fs/FileSystemCache.java |  2 +-
 .../java/org/apache/doris/common/CacheFactoryTest.java | 18 +++++++++---------
 17 files changed, 60 insertions(+), 54 deletions(-)

diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java 
b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
index 879e48b204c..cb41a970ace 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
@@ -2210,12 +2210,17 @@ public class Config extends ConfigBase {
     @ConfField(mutable = false, masterOnly = false)
     public static long max_external_schema_cache_num = 10000;
 
-    /**
-     * The expiration time of a cache object after last access of it.
-     * For external schema cache and hive meta cache.
-     */
-    @ConfField(mutable = false, masterOnly = false)
-    public static long external_cache_expire_time_minutes_after_access = 10; 
// 10 mins
+    @ConfField(description = {
+            "外部表元数据缓存对象在最后访问后过期的时间。",
+            "The expiration time of a cache object after last access of it. 
For external meta cache."
+    })
+    public static long external_cache_expire_time_seconds_after_access = 
86400L; // 24 hours
+
+    @ConfField(description = {
+            "外部表元数据缓存对象的自动刷新时间",
+            "The auto refresh time of external meta cache."
+    })
+    public static long external_cache_refresh_time_minutes = 10; // 10 mins
 
     /**
      * Github workflow test type, for setting some session variables
diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/CacheFactory.java 
b/fe/fe-core/src/main/java/org/apache/doris/common/CacheFactory.java
index 50f46647975..2b5e6968d17 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/CacheFactory.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/CacheFactory.java
@@ -46,7 +46,7 @@ import java.util.concurrent.ExecutorService;
  */
 public class CacheFactory {
 
-    private OptionalLong expireAfterWriteSec;
+    private OptionalLong expireAfterAccessSec;
     private OptionalLong refreshAfterWriteSec;
     private long maxSize;
     private boolean enableStats;
@@ -56,12 +56,12 @@ public class CacheFactory {
     private Ticker ticker;
 
     public CacheFactory(
-            OptionalLong expireAfterWriteSec,
+            OptionalLong expireAfterAccessSec,
             OptionalLong refreshAfterWriteSec,
             long maxSize,
             boolean enableStats,
             Ticker ticker) {
-        this.expireAfterWriteSec = expireAfterWriteSec;
+        this.expireAfterAccessSec = expireAfterAccessSec;
         this.refreshAfterWriteSec = refreshAfterWriteSec;
         this.maxSize = maxSize;
         this.enableStats = enableStats;
@@ -98,8 +98,8 @@ public class CacheFactory {
         Caffeine<Object, Object> builder = Caffeine.newBuilder();
         builder.maximumSize(maxSize);
 
-        if (expireAfterWriteSec.isPresent()) {
-            
builder.expireAfterWrite(Duration.ofSeconds(expireAfterWriteSec.getAsLong()));
+        if (expireAfterAccessSec.isPresent()) {
+            
builder.expireAfterAccess(Duration.ofSeconds(expireAfterAccessSec.getAsLong()));
         }
         if (refreshAfterWriteSec.isPresent()) {
             
builder.refreshAfterWrite(Duration.ofSeconds(refreshAfterWriteSec.getAsLong()));
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java
index ec91c396eb1..29287dc57b6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java
@@ -315,8 +315,8 @@ public abstract class ExternalCatalog
                     if (metaCache == null) {
                         metaCache = 
Env.getCurrentEnv().getExtMetaCacheMgr().buildMetaCache(
                                 name,
-                                OptionalLong.of(86400L),
-                                
OptionalLong.of(Config.external_cache_expire_time_minutes_after_access * 60L),
+                                
OptionalLong.of(Config.external_cache_expire_time_seconds_after_access),
+                                
OptionalLong.of(Config.external_cache_refresh_time_minutes * 60L),
                                 Config.max_meta_object_cache_num,
                                 ignored -> getFilteredDatabaseNames(),
                                 localDbName -> Optional.ofNullable(
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalDatabase.java 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalDatabase.java
index 7dea087c5ee..7a32c22d9c6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalDatabase.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalDatabase.java
@@ -167,8 +167,8 @@ public abstract class ExternalDatabase<T extends 
ExternalTable>
                     if (metaCache == null) {
                         metaCache = 
Env.getCurrentEnv().getExtMetaCacheMgr().buildMetaCache(
                                 name,
-                                OptionalLong.of(86400L),
-                                
OptionalLong.of(Config.external_cache_expire_time_minutes_after_access * 60L),
+                                
OptionalLong.of(Config.external_cache_expire_time_seconds_after_access),
+                                
OptionalLong.of(Config.external_cache_refresh_time_minutes * 60L),
                                 Config.max_meta_object_cache_num,
                                 ignored -> listTableNames(),
                                 localTableName -> Optional.ofNullable(
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalMetaCacheMgr.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalMetaCacheMgr.java
index 990c825927e..aa53a8f3142 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalMetaCacheMgr.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalMetaCacheMgr.java
@@ -344,11 +344,12 @@ public class ExternalMetaCacheMgr {
     }
 
     public <T> MetaCache<T> buildMetaCache(String name,
-            OptionalLong expireAfterWriteSec, OptionalLong 
refreshAfterWriteSec, long maxSize,
+            OptionalLong expireAfterAccessSec, OptionalLong 
refreshAfterWriteSec, long maxSize,
             CacheLoader<String, List<Pair<String, String>>> namesCacheLoader,
             CacheLoader<String, Optional<T>> metaObjCacheLoader,
             RemovalListener<String, Optional<T>> removalListener) {
-        MetaCache<T> metaCache = new MetaCache<>(name, commonRefreshExecutor, 
expireAfterWriteSec, refreshAfterWriteSec,
+        MetaCache<T> metaCache = new MetaCache<>(
+                name, commonRefreshExecutor, expireAfterAccessSec, 
refreshAfterWriteSec,
                 maxSize, namesCacheLoader, metaObjCacheLoader, 
removalListener);
         return metaCache;
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalRowCountCache.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalRowCountCache.java
index a00d9f12857..4fc191b2f7f 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalRowCountCache.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalRowCountCache.java
@@ -43,8 +43,8 @@ public class ExternalRowCountCache {
         // 1. set expireAfterWrite to 1 day, avoid too many entries
         // 2. set refreshAfterWrite to 10min(default), so that the cache will 
be refreshed after 10min
         CacheFactory rowCountCacheFactory = new CacheFactory(
-                OptionalLong.of(86400L),
-                
OptionalLong.of(Config.external_cache_expire_time_minutes_after_access * 60),
+                
OptionalLong.of(Config.external_cache_expire_time_seconds_after_access),
+                OptionalLong.of(Config.external_cache_refresh_time_minutes * 
60),
                 Config.max_external_table_row_count_cache_num,
                 false,
                 null);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalSchemaCache.java 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalSchemaCache.java
index da9a25d71be..07946ad6619 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalSchemaCache.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalSchemaCache.java
@@ -56,8 +56,8 @@ public class ExternalSchemaCache {
                 
(catalog.getProperties().get(ExternalCatalog.SCHEMA_CACHE_TTL_SECOND)), 
ExternalCatalog.CACHE_NO_TTL);
         CacheFactory schemaCacheFactory = new CacheFactory(
                 OptionalLong.of(schemaCacheTtlSecond >= 
ExternalCatalog.CACHE_TTL_DISABLE_CACHE
-                        ? schemaCacheTtlSecond : 86400),
-                
OptionalLong.of(Config.external_cache_expire_time_minutes_after_access * 60),
+                        ? schemaCacheTtlSecond : 
Config.external_cache_expire_time_seconds_after_access),
+                OptionalLong.of(Config.external_cache_refresh_time_minutes * 
60),
                 Config.max_external_schema_cache_num,
                 false,
                 null);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
index 314162d3f0d..a599552fc11 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreCache.java
@@ -144,8 +144,8 @@ public class HiveMetaStoreCache {
 
         CacheFactory partitionValuesCacheFactory = new CacheFactory(
                 OptionalLong.of(partitionCacheTtlSecond >= 
ExternalCatalog.CACHE_TTL_DISABLE_CACHE
-                        ? partitionCacheTtlSecond : 28800L),
-                
OptionalLong.of(Config.external_cache_expire_time_minutes_after_access * 60L),
+                        ? partitionCacheTtlSecond : 
Config.external_cache_expire_time_seconds_after_access),
+                OptionalLong.of(Config.external_cache_refresh_time_minutes * 
60L),
                 Config.max_hive_partition_table_cache_num,
                 true,
                 null);
@@ -153,7 +153,7 @@ public class HiveMetaStoreCache {
                 refreshExecutor);
 
         CacheFactory partitionCacheFactory = new CacheFactory(
-                OptionalLong.of(28800L),
+                
OptionalLong.of(Config.external_cache_expire_time_seconds_after_access),
                 OptionalLong.empty(),
                 Config.max_hive_partition_cache_num,
                 true,
@@ -186,8 +186,8 @@ public class HiveMetaStoreCache {
 
         CacheFactory fileCacheFactory = new CacheFactory(
                 OptionalLong.of(fileMetaCacheTtlSecond >= 
ExternalCatalog.CACHE_TTL_DISABLE_CACHE
-                        ? fileMetaCacheTtlSecond : 28800L),
-                
OptionalLong.of(Config.external_cache_expire_time_minutes_after_access * 60L),
+                        ? fileMetaCacheTtlSecond : 
Config.external_cache_expire_time_seconds_after_access),
+                OptionalLong.of(Config.external_cache_refresh_time_minutes * 
60L),
                 Config.max_external_file_cache_num,
                 true,
                 null);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hudi/source/HudiCachedFsViewProcessor.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hudi/source/HudiCachedFsViewProcessor.java
index bbbe87cac87..9516f8a0c30 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hudi/source/HudiCachedFsViewProcessor.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hudi/source/HudiCachedFsViewProcessor.java
@@ -41,8 +41,8 @@ public class HudiCachedFsViewProcessor {
 
     public HudiCachedFsViewProcessor(ExecutorService executor) {
         CacheFactory partitionCacheFactory = new CacheFactory(
-                OptionalLong.of(28800L),
-                
OptionalLong.of(Config.external_cache_expire_time_minutes_after_access * 60),
+                
OptionalLong.of(Config.external_cache_expire_time_seconds_after_access),
+                OptionalLong.of(Config.external_cache_refresh_time_minutes * 
60),
                 Config.max_external_table_cache_num,
                 true,
                 null);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hudi/source/HudiCachedMetaClientProcessor.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hudi/source/HudiCachedMetaClientProcessor.java
index 9ed1007e804..67bd6c72c81 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hudi/source/HudiCachedMetaClientProcessor.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hudi/source/HudiCachedMetaClientProcessor.java
@@ -41,8 +41,8 @@ public class HudiCachedMetaClientProcessor {
 
     public HudiCachedMetaClientProcessor(ExecutorService executor) {
         CacheFactory partitionCacheFactory = new CacheFactory(
-                OptionalLong.of(28800L),
-                
OptionalLong.of(Config.external_cache_expire_time_minutes_after_access * 60),
+                
OptionalLong.of(Config.external_cache_expire_time_seconds_after_access),
+                OptionalLong.of(Config.external_cache_refresh_time_minutes * 
60),
                 Config.max_external_table_cache_num,
                 true,
                 null);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hudi/source/HudiCachedPartitionProcessor.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hudi/source/HudiCachedPartitionProcessor.java
index f302458f8ca..6ecc9e2efdd 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hudi/source/HudiCachedPartitionProcessor.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hudi/source/HudiCachedPartitionProcessor.java
@@ -56,8 +56,8 @@ public class HudiCachedPartitionProcessor extends 
HudiPartitionProcessor {
         this.catalogId = catalogId;
         this.executor = executor;
         CacheFactory partitionCacheFactory = new CacheFactory(
-                OptionalLong.of(28800L),
-                
OptionalLong.of(Config.external_cache_expire_time_minutes_after_access * 60),
+                
OptionalLong.of(Config.external_cache_expire_time_seconds_after_access),
+                OptionalLong.of(Config.external_cache_refresh_time_minutes * 
60),
                 Config.max_external_table_cache_num,
                 true,
                 null);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataCache.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataCache.java
index f99b652b42d..e41fa620b9c 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataCache.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataCache.java
@@ -52,24 +52,24 @@ public class IcebergMetadataCache {
 
     public IcebergMetadataCache(ExecutorService executor) {
         CacheFactory snapshotListCacheFactory = new CacheFactory(
-                OptionalLong.of(28800L),
-                
OptionalLong.of(Config.external_cache_expire_time_minutes_after_access * 60),
+                
OptionalLong.of(Config.external_cache_expire_time_seconds_after_access),
+                OptionalLong.of(Config.external_cache_refresh_time_minutes * 
60),
                 Config.max_external_table_cache_num,
                 true,
                 null);
         this.snapshotListCache = snapshotListCacheFactory.buildCache(key -> 
loadSnapshots(key), null, executor);
 
         CacheFactory tableCacheFactory = new CacheFactory(
-                OptionalLong.of(28800L),
-                
OptionalLong.of(Config.external_cache_expire_time_minutes_after_access * 60),
+                
OptionalLong.of(Config.external_cache_expire_time_seconds_after_access),
+                OptionalLong.of(Config.external_cache_refresh_time_minutes * 
60),
                 Config.max_external_table_cache_num,
                 true,
                 null);
         this.tableCache = tableCacheFactory.buildCache(key -> loadTable(key), 
null, executor);
 
         CacheFactory snapshotCacheFactory = new CacheFactory(
-                OptionalLong.of(28800L),
-                
OptionalLong.of(Config.external_cache_expire_time_minutes_after_access * 60),
+                
OptionalLong.of(Config.external_cache_expire_time_seconds_after_access),
+                OptionalLong.of(Config.external_cache_refresh_time_minutes * 
60),
                 Config.max_external_table_cache_num,
                 true,
                 null);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeMetadataCache.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeMetadataCache.java
index 2213ded0bcb..f2a9b78fd9f 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeMetadataCache.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/MaxComputeMetadataCache.java
@@ -33,7 +33,7 @@ public class MaxComputeMetadataCache {
 
     public MaxComputeMetadataCache() {
         partitionValuesCache = 
Caffeine.newBuilder().maximumSize(Config.max_hive_partition_cache_num)
-                
.expireAfterAccess(Config.external_cache_expire_time_minutes_after_access, 
TimeUnit.MINUTES)
+                .expireAfterAccess(Config.external_cache_refresh_time_minutes, 
TimeUnit.MINUTES)
                 .build();
     }
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/MetaCache.java 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/MetaCache.java
index 51692b609a6..dc2670a83c6 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/MetaCache.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/MetaCache.java
@@ -45,7 +45,7 @@ public class MetaCache<T> {
 
     public MetaCache(String name,
             ExecutorService executor,
-            OptionalLong expireAfterWriteSec,
+            OptionalLong expireAfterAccessSec,
             OptionalLong refreshAfterWriteSec,
             long maxSize,
             CacheLoader<String, List<Pair<String, String>>> namesCacheLoader,
@@ -60,13 +60,13 @@ public class MetaCache<T> {
         // from remote datasource, it is just a local generated object to 
represent the meta info.
         // So it only need to be expired after specified duration.
         CacheFactory namesCacheFactory = new CacheFactory(
-                expireAfterWriteSec,
+                expireAfterAccessSec,
                 refreshAfterWriteSec,
                 1, // names cache has one and only one entry
                 true,
                 null);
         CacheFactory objCacheFactory = new CacheFactory(
-                expireAfterWriteSec,
+                expireAfterAccessSec,
                 OptionalLong.empty(),
                 maxSize,
                 true,
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonMetadataCache.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonMetadataCache.java
index d5b49aa82d3..b16715e8238 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonMetadataCache.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonMetadataCache.java
@@ -48,8 +48,8 @@ public class PaimonMetadataCache {
 
     public PaimonMetadataCache(ExecutorService executor) {
         CacheFactory snapshotCacheFactory = new CacheFactory(
-                OptionalLong.of(28800L),
-                
OptionalLong.of(Config.external_cache_expire_time_minutes_after_access * 60),
+                
OptionalLong.of(Config.external_cache_expire_time_seconds_after_access),
+                OptionalLong.of(Config.external_cache_refresh_time_minutes * 
60),
                 Config.max_external_table_cache_num,
                 true,
                 null);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemCache.java 
b/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemCache.java
index e96258dc719..a6f54df22ef 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemCache.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemCache.java
@@ -37,7 +37,7 @@ public class FileSystemCache {
     public FileSystemCache() {
         // no need to set refreshAfterWrite, because the FileSystem is created 
once and never changed
         CacheFactory fsCacheFactory = new CacheFactory(
-                OptionalLong.of(86400L),
+                
OptionalLong.of(Config.external_cache_expire_time_seconds_after_access),
                 OptionalLong.empty(),
                 Config.max_remote_file_system_cache_num,
                 false,
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/common/CacheFactoryTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/common/CacheFactoryTest.java
index 44ca185d611..98b8517692a 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/common/CacheFactoryTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/common/CacheFactoryTest.java
@@ -149,7 +149,7 @@ public class CacheFactoryTest {
         FakeTicker ticker = new FakeTicker();
         AtomicLong counter = new AtomicLong(0);
         CacheFactory cacheFactory = new CacheFactory(
-                OptionalLong.of(60L),
+                OptionalLong.of(20L),
                 OptionalLong.of(10),
                 1000,
                 false,
@@ -174,8 +174,8 @@ public class CacheFactoryTest {
         Assertions.assertEquals("value1", value.getValue());
         // refreshed, so counter +1
         Assertions.assertEquals(2, counter.get());
-        // advance 61 seconds to pass the expireAfterWrite
-        ticker.advance(61, TimeUnit.SECONDS);
+        // advance 21 seconds to pass the expireAfterAccess
+        ticker.advance(21, TimeUnit.SECONDS);
         value = loadingCache.get(1);
         Assertions.assertEquals("value1", value.getValue());
         // expired, so counter +1
@@ -187,7 +187,7 @@ public class CacheFactoryTest {
         FakeTicker ticker = new FakeTicker();
         AtomicLong counter = new AtomicLong(0);
         CacheFactory cacheFactory = new CacheFactory(
-                OptionalLong.of(60L),
+                OptionalLong.of(6L),
                 OptionalLong.empty(),
                 1000,
                 false,
@@ -197,13 +197,13 @@ public class CacheFactoryTest {
         CacheValue value = loadingCache.get(1);
         Assertions.assertEquals("value1", value.getValue());
         Assertions.assertEquals(1, counter.get());
-        // advance 30 seconds, key still not expired
-        ticker.advance(30, TimeUnit.SECONDS);
+        // advance 1 seconds, key still not expired
+        ticker.advance(1, TimeUnit.SECONDS);
         value = loadingCache.get(1);
         Assertions.assertEquals("value1", value.getValue());
         Assertions.assertEquals(1, counter.get());
-        // advance 31 seconds to pass the expireAfterWrite
-        ticker.advance(31, TimeUnit.SECONDS);
+        // advance 7 seconds to pass the expireAfterAccess
+        ticker.advance(7, TimeUnit.SECONDS);
         value = loadingCache.get(1);
         Assertions.assertEquals("value1", value.getValue());
         // expired, so counter +1
@@ -243,7 +243,7 @@ public class CacheFactoryTest {
         Assertions.assertEquals("value1", futureValue.get().get().getValue());
         // refreshed, so counter +1
         Assertions.assertEquals(2, counter.get());
-        // advance 61 seconds to pass the expireAfterWrite
+        // advance 61 seconds to pass the expireAfterAccess
         ticker.advance(61, TimeUnit.SECONDS);
         futureValue = loadingCache.get(1);
         Assertions.assertFalse(futureValue.isDone());


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to