diff options
author | vnugent <public@vaughnnugent.com> | 2024-07-15 19:01:28 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-07-15 19:01:28 -0400 |
commit | 24929f4e7acce9847f4cbe813e850ee57d474723 (patch) | |
tree | 3764dfcc9212975be7b5238349412f9cc45e4b3c /plugins/VNLib.Data.Caching.Providers.VNCache/src/Clustering | |
parent | 5e8f5f87b243930e17bfe99a34e170161204b4e1 (diff) |
refactor: Update entity result caching
Diffstat (limited to 'plugins/VNLib.Data.Caching.Providers.VNCache/src/Clustering')
-rw-r--r-- | plugins/VNLib.Data.Caching.Providers.VNCache/src/Clustering/ClusterNodeIndex.cs | 18 |
1 files changed, 13 insertions, 5 deletions
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; } ///<inheritdoc/> @@ -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<string?> _remoteSerializer = ManagedLibrary.GetMethod<Func<string?>>(RemoteIndex, nameof(LocalHandler.SerializeNextNode), BindingFlags.NonPublic); + private readonly Func<string?> _remoteSerializer + = ManagedLibrary.GetMethod<Func<string?>>(RemoteIndex, nameof(LocalHandler.SerializeNextNode), BindingFlags.NonPublic); - private readonly Func<CancellationToken, Task> _waitTask = ManagedLibrary.GetMethod<Func<CancellationToken, Task>>(RemoteIndex, nameof(WaitForDiscoveryAsync), BindingFlags.Public); + private readonly Func<CancellationToken, Task> _waitTask + = ManagedLibrary.GetMethod<Func<CancellationToken, Task>>(RemoteIndex, nameof(LocalHandler.WaitForDiscoveryAsync), BindingFlags.Public); ///<inheritdoc/> public CacheNodeAdvertisment? GetNextNode() { //Deserialize the next node from the remote index string? nexNode = _remoteSerializer(); - return nexNode == null ? null : JsonSerializer.Deserialize<CacheNodeAdvertisment>(nexNode); + return nexNode is not null + ? JsonSerializer.Deserialize<CacheNodeAdvertisment>(nexNode) + : null; } ///<inheritdoc/> |