Unverified Commit 1ec4d28e authored by ZackYoung's avatar ZackYoung Committed by GitHub

[BugFix] [Metadata] fix metadata cache And add an expiration date (#3198)

parent daf59c75
......@@ -37,6 +37,7 @@ import com.alibaba.fastjson2.JSONWriter;
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<CacheData> clazz = CacheData.class;
......@@ -45,7 +46,7 @@ public class PaimonCache extends AbstractValueAdaptingCache {
/**
* TIMEOUT CACHE
*/
private final cn.hutool.cache.Cache<Object, Object> cache = new TimedCache<>(1000 * 60 * 30);
private final cn.hutool.cache.Cache<Object, Object> cache = new TimedCache<>(1000 * 60 * 10);
public PaimonCache(String cacheName) {
super(true);
......@@ -98,6 +99,7 @@ public class PaimonCache extends AbstractValueAdaptingCache {
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))
......
......@@ -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")
......
......@@ -40,8 +40,14 @@ import lombok.Setter;
@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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment