(improvement)(chat) dsl supports revision and fix queryDimensionValue performance (#188)

This commit is contained in:
mainmain
2023-10-10 21:28:42 +08:00
committed by GitHub
parent 3b1cbd4fd7
commit 278af3ce34
3 changed files with 89 additions and 34 deletions

View File

@@ -17,13 +17,14 @@ import org.springframework.util.CollectionUtils;
public abstract class BaseSemanticInterpreter implements SemanticInterpreter {
protected final Cache<String, List<ModelSchemaResp>> modelSchemaCache =
CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.SECONDS).build();
CacheBuilder.newBuilder().expireAfterWrite(60, TimeUnit.SECONDS).build();
@SneakyThrows
public List<ModelSchemaResp> fetchModelSchema(List<Long> ids, Boolean cacheEnable) {
if (cacheEnable) {
return modelSchemaCache.get(String.valueOf(ids), () -> {
List<ModelSchemaResp> data = doFetchModelSchema(ids);
modelSchemaCache.put(String.valueOf(ids), data);
return data;
});
}