MatrixHB commented on code in PR #76: URL: https://github.com/apache/rocketmq-schema-registry/pull/76#discussion_r1090308954
########## client/src/main/java/org/apache/rocketmq/schema/registry/client/CachedSchemaRegistryClient.java: ########## @@ -0,0 +1,485 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.rocketmq.schema.registry.client; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import lombok.AllArgsConstructor; +import org.apache.rocketmq.schema.registry.client.exceptions.RestClientException; +import org.apache.rocketmq.schema.registry.client.rest.RestService; + +import java.io.IOException; +import java.util.List; +import org.apache.rocketmq.schema.registry.common.dto.GetSchemaResponse; +import org.apache.rocketmq.schema.registry.common.dto.DeleteSchemeResponse; +import org.apache.rocketmq.schema.registry.common.dto.RegisterSchemaRequest; +import org.apache.rocketmq.schema.registry.common.dto.RegisterSchemaResponse; +import org.apache.rocketmq.schema.registry.common.dto.SchemaRecordDto; +import org.apache.rocketmq.schema.registry.common.dto.UpdateSchemaRequest; +import org.apache.rocketmq.schema.registry.common.dto.UpdateSchemaResponse; + +public class CachedSchemaRegistryClient implements SchemaRegistryClient { + + private static final String DEFAULT_TENANT = "default"; + private static final String DEFAULT_CLUSTER = "default"; + private static final int DEFAULT_CAPACITY = 100; + private static final int DEFAULT_DURATION = 10; + + private final RestService restService; + + private final Map<String, Set<Long>> subjectToId; // restore recordIds that cached in SubjectAndId Review Comment: This map is only used to invalidate the cache when doing the delete schema action. It's better to add some comment details -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
