Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading