Skip to content

Commit

Permalink
fix_metadata_cache
Browse files Browse the repository at this point in the history
  • Loading branch information
zackyoungh committed Feb 28, 2024
1 parent daf59c7 commit 6fecdee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<CacheData> clazz = CacheData.class;
Expand All @@ -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);
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6fecdee

Please sign in to comment.