diff --git a/dinky-admin/src/main/java/org/dinky/configure/cache/PaimonCache.java b/dinky-admin/src/main/java/org/dinky/configure/cache/PaimonCache.java index e4106e5223..4f10645517 100644 --- a/dinky-admin/src/main/java/org/dinky/configure/cache/PaimonCache.java +++ b/dinky-admin/src/main/java/org/dinky/configure/cache/PaimonCache.java @@ -37,6 +37,7 @@ import cn.hutool.cache.impl.TimedCache; import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateUtil; public class PaimonCache extends AbstractValueAdaptingCache { private static final Class clazz = CacheData.class; @@ -45,7 +46,7 @@ public class PaimonCache extends AbstractValueAdaptingCache { /** * TIMEOUT CACHE */ - private final cn.hutool.cache.Cache cache = new TimedCache<>(1000 * 60 * 30); + private final cn.hutool.cache.Cache cache = new TimedCache<>(1000 * 60 * 10); public PaimonCache(String cacheName) { super(true); @@ -98,6 +99,7 @@ public void put(Object key, Object value) { cache.put(strKey, value); PaimonUtil.createOrGetTable(TABLE_NAME, clazz); CacheData cacheData = CacheData.builder() + .cacheTime(DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm")) .cacheName(cacheName) .key(strKey) .data(serialize(value)) diff --git a/dinky-admin/src/main/java/org/dinky/controller/DataSourceController.java b/dinky-admin/src/main/java/org/dinky/controller/DataSourceController.java index 27a487c78f..e68fb3e07f 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/DataSourceController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/DataSourceController.java @@ -78,6 +78,7 @@ public class DataSourceController { * @param dataBaseDTO {@link DataBaseDTO} * @return {@link Result}< {@link Void}> */ + @CacheEvict(cacheNames = "metadata_schema", key = "#dataBaseDTO.id") @PutMapping("/saveOrUpdate") @Log(title = "Insert Or Update DataBase", businessType = BusinessType.INSERT_OR_UPDATE) @ApiOperation("Insert Or Update DataBase") diff --git a/dinky-common/src/main/java/org/dinky/data/paimon/CacheData.java b/dinky-common/src/main/java/org/dinky/data/paimon/CacheData.java index 3bc0c70325..acb11f8161 100644 --- a/dinky-common/src/main/java/org/dinky/data/paimon/CacheData.java +++ b/dinky-common/src/main/java/org/dinky/data/paimon/CacheData.java @@ -40,8 +40,14 @@ @Options({ @Option(key = "file.format", value = "parquet"), @Option(key = "snapshot.time-retained", value = "10 s"), + @Option(key = "partition.expiration-time", value = "10min"), + @Option(key = "partition.expiration-check-interval", value = "2min"), + @Option(key = "partition.timestamp-formatter", value = "yyyy-MM-dd HH:mm"), + @Option(key = "partition.timestamp-pattern", value = "$cacheTime"), }) public class CacheData implements Serializable { + @PartitionKey + private String cacheTime; @PartitionKey private String cacheName;