From 24929f4e7acce9847f4cbe813e850ee57d474723 Mon Sep 17 00:00:00 2001 From: vnugent Date: Mon, 15 Jul 2024 19:01:28 -0400 Subject: refactor: Update entity result caching --- .../src/Clustering/ClusterNodeIndex.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'plugins/VNLib.Data.Caching.Providers.VNCache/src/Clustering') diff --git a/plugins/VNLib.Data.Caching.Providers.VNCache/src/Clustering/ClusterNodeIndex.cs b/plugins/VNLib.Data.Caching.Providers.VNCache/src/Clustering/ClusterNodeIndex.cs index e9dcbc5..effa4d7 100644 --- a/plugins/VNLib.Data.Caching.Providers.VNCache/src/Clustering/ClusterNodeIndex.cs +++ b/plugins/VNLib.Data.Caching.Providers.VNCache/src/Clustering/ClusterNodeIndex.cs @@ -124,7 +124,9 @@ namespace VNLib.Data.Caching.Providers.VNCache.Clustering //Get all discovered nodes CacheNodeAdvertisment[] ads = cluster.DiscoveredNodes.GetAllNodes(); //Just get a random node from the collection for now - return ads.Length > 0 ? ads.SelectRandom() : null; + return ads.Length > 0 + ? ads.SelectRandom() + : null; } /// @@ -145,22 +147,28 @@ namespace VNLib.Data.Caching.Providers.VNCache.Clustering internal string? SerializeNextNode() { CacheNodeAdvertisment? nextNode = GetNextNode(); - return nextNode == null ? null : JsonSerializer.Serialize(nextNode); + return nextNode is not null + ? JsonSerializer.Serialize(nextNode) + : null; } } sealed class RemoteHandler(object RemoteIndex) : IClusterNodeIndex { - private readonly Func _remoteSerializer = ManagedLibrary.GetMethod>(RemoteIndex, nameof(LocalHandler.SerializeNextNode), BindingFlags.NonPublic); + private readonly Func _remoteSerializer + = ManagedLibrary.GetMethod>(RemoteIndex, nameof(LocalHandler.SerializeNextNode), BindingFlags.NonPublic); - private readonly Func _waitTask = ManagedLibrary.GetMethod>(RemoteIndex, nameof(WaitForDiscoveryAsync), BindingFlags.Public); + private readonly Func _waitTask + = ManagedLibrary.GetMethod>(RemoteIndex, nameof(LocalHandler.WaitForDiscoveryAsync), BindingFlags.Public); /// public CacheNodeAdvertisment? GetNextNode() { //Deserialize the next node from the remote index string? nexNode = _remoteSerializer(); - return nexNode == null ? null : JsonSerializer.Deserialize(nexNode); + return nexNode is not null + ? JsonSerializer.Deserialize(nexNode) + : null; } /// -- cgit