junichi11 commented on code in PR #7618: URL: https://github.com/apache/netbeans/pull/7618#discussion_r1731974124
########## php/php.blade/src/org/netbeans/modules/php/blade/editor/cache/QueryCache.java: ########## @@ -0,0 +1,111 @@ +/* + * 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.netbeans.modules.php.blade.editor.cache; + +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * + * @author bogdan + */ +public final class QueryCache<K, V> { + + public static final Long DEFAULT_CACHE_TIMEOUT = 60000L; + + private Map<K, CacheValue<V>> cacheMap; + private Long cacheTimeout; + + //private static final Map<QuerySupport, QueryCache> QUERY_SUPPORT_INDEX = new WeakHashMap<>(); + + public QueryCache() { + this(DEFAULT_CACHE_TIMEOUT); + } + + public QueryCache(Long cacheTimeout) { + this.cacheTimeout = cacheTimeout; + this.clear(); + } + + public void clean() { + for (K key : this.getExpiredKeys()) { + this.remove(key); + } + } + + public boolean containsKey(K key) { + return this.cacheMap.containsKey(key); + } + + protected Set<K> getExpiredKeys() { Review Comment: `private`? (Why `protected`?) -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
