/* ========================================================================
* Copyright (c) 2005-2025 The OPC Foundation, Inc. All rights reserved.
*
* OPC Foundation MIT License 1.00
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* The complete license agreement can be found here:
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/
using System.Threading;
using System.Threading.Tasks;
namespace Opc.Ua.Client
{
///
/// Client-side cache of the server's address space. Combines the
/// /
/// surface (ExpandedNodeId-keyed, nullable, may fetch from the
/// server) with NodeId-keyed direct accessors for callers that
/// already hold a local .
///
///
///
/// The interface is intentionally minimal. Two complementary
/// families of lookups exist:
///
///
/// -
/// Inherited Find*
///
/// From /
/// : ExpandedNodeId-keyed,
/// returns null on miss, may fetch from the server
/// and updates the cache. Suitable for callers that have not
/// yet resolved the namespace index.
///
///
/// -
/// Get*
///
/// Defined here: NodeId-keyed, throws when the node cannot
/// be resolved, expected hot-path for traversals where the
/// caller already has a local . The
/// cache-fast-path returns synchronously.
///
///
///
///
/// Convenience helpers (display text, browse path traversal,
/// built-in type resolution, ExpandedNodeId variants of
/// Get*) live as static extension methods on
/// .
///
///
/// All asynchronous operations return /
/// . is intentionally
/// synchronous because it is a pure local-state mutation with no
/// I/O.
///
///
public interface INodeCache : IAsyncNodeTable, IAsyncTypeTable
{
///
/// Removes all cached nodes, references and values. Pure
/// local-state mutation — does not contact the server.
///
void Clear();
///
/// Invalidates a single cached node, dropping its cached
/// state and references. Pure local-state mutation — does
/// not contact the server.
///
///
/// Implementations that cannot perform per-node eviction may
/// fall back to .
/// performs true per-node eviction.
///
/// The node id to invalidate.
void InvalidateNode(NodeId nodeId);
///
/// Force-fetches a node from the server and updates the cache.
/// Returns null when the node does not exist or cannot
/// be read.
///
ValueTask FetchNodeAsync(
ExpandedNodeId nodeId,
CancellationToken ct = default);
///
/// Force-fetches a node collection from the server and updates
/// the cache.
///
ValueTask> FetchNodesAsync(
ArrayOf nodeIds,
CancellationToken ct = default);
///
/// Get a node from the cache by local .
/// Fetches from the server if not cached. Throws when the node
/// cannot be resolved.
///
ValueTask GetNodeAsync(
NodeId nodeId,
CancellationToken ct = default);
///
/// Get a node collection from the cache by local
/// s. Fetches missing entries from the
/// server.
///
ValueTask> GetNodesAsync(
ArrayOf nodeIds,
CancellationToken ct = default);
///
/// Get the value of a node from the cache. Fetches if not
/// cached.
///
ValueTask GetValueAsync(
NodeId nodeId,
CancellationToken ct = default);
///
/// Get values for a node collection.
///
ValueTask> GetValuesAsync(
ArrayOf nodeIds,
CancellationToken ct = default);
///
/// Get the references for a node by reference type.
///
ValueTask> GetReferencesAsync(
NodeId nodeId,
NodeId referenceTypeId,
bool isInverse,
bool includeSubtypes = true,
CancellationToken ct = default);
///
/// Get the references for a node collection by reference type
/// collection.
///
ValueTask> GetReferencesAsync(
ArrayOf nodeIds,
ArrayOf referenceTypeIds,
bool isInverse,
bool includeSubtypes = true,
CancellationToken ct = default);
///
/// Pre-load the type hierarchy for the supplied type ids so
/// subsequent
/// / calls are
/// served from the cache.
///
ValueTask LoadTypeHierarchyAsync(
ArrayOf typeIds,
CancellationToken ct = default);
}
}