Skip to content

Commit

Permalink
add catalog meta cache
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyongxiang.alpha committed Jan 10, 2025
1 parent fc1d05a commit d7b9582
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public class AmoroManagementConf {
.defaultValue("admin")
.withDescription("The administrator password");

public static final ConfigOption<Duration> CACHE_CATALOG_META_DURATION =
ConfigOptions.key("cache.catalog-meta.duration")
public static final ConfigOption<Duration> CATALOG_META_CACHE_EXPIRATION_INTERVAL =
ConfigOptions.key("catalog-meta-cache.expiration-interval")
.durationType()
.defaultValue(Duration.ofSeconds(60))
.withDescription("TTL for catalog metadata.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public class DefaultCatalogManager extends PersistentBase implements CatalogMana

public DefaultCatalogManager(Configurations serverConfiguration) {
this.serverConfiguration = serverConfiguration;
Duration cacheTtl = serverConfiguration.get(AmoroManagementConf.CACHE_CATALOG_META_DURATION);
Duration cacheTtl =
serverConfiguration.get(AmoroManagementConf.CATALOG_META_CACHE_EXPIRATION_INTERVAL);
metaCache =
CacheBuilder.newBuilder()
.maximumSize(100)
Expand Down Expand Up @@ -80,8 +81,7 @@ public DefaultCatalogManager(Configurations serverConfiguration) {

@Override
public List<CatalogMeta> listCatalogMetas() {
return getAs(CatalogMetaMapper.class, CatalogMetaMapper::getCatalogs)
.stream()
return getAs(CatalogMetaMapper.class, CatalogMetaMapper::getCatalogs).stream()
.peek(c -> metaCache.put(c.getCatalogName(), Optional.of(c)))
.collect(Collectors.toList());
}
Expand Down
5 changes: 2 additions & 3 deletions dist/src/main/amoro-bin/conf/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ ams:
table-manifest-io:
thread-count: 20

cache:
catalog-meta:
duration: 60s
catalog-meta-cache:
expiration-interval: 60s

database:
type: derby
Expand Down

0 comments on commit d7b9582

Please sign in to comment.