org.eclipse.milo.opcua.sdk.client.NodeCache Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2021 the Eclipse Milo Authors
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.milo.opcua.sdk.client;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.eclipse.milo.opcua.sdk.client.nodes.UaNode;
import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
import org.jetbrains.annotations.Nullable;
public class NodeCache {
private final Cache cachedNodes;
private final ConcurrentMap canonicalNodes;
public NodeCache() {
this(builder -> {
builder.expireAfterWrite(2, TimeUnit.MINUTES);
builder.maximumSize(16384);
builder.recordStats();
});
}
public NodeCache(Consumer> consumer) {
CacheBuilder