From 718bed529299ea9aad03d848b835cbda1854be34 Mon Sep 17 00:00:00 2001 From: vnugent Date: Thu, 2 Nov 2023 21:35:08 -0400 Subject: Remove ambiguous default serializer functions --- .../src/FBMCacheClient.cs | 42 ++++++++-------------- 1 file changed, 14 insertions(+), 28 deletions(-) (limited to 'plugins/VNLib.Data.Caching.Providers.VNCache/src/FBMCacheClient.cs') diff --git a/plugins/VNLib.Data.Caching.Providers.VNCache/src/FBMCacheClient.cs b/plugins/VNLib.Data.Caching.Providers.VNCache/src/FBMCacheClient.cs index f952bcb..7132212 100644 --- a/plugins/VNLib.Data.Caching.Providers.VNCache/src/FBMCacheClient.cs +++ b/plugins/VNLib.Data.Caching.Providers.VNCache/src/FBMCacheClient.cs @@ -51,7 +51,7 @@ namespace VNLib.Data.Caching.Providers.VNCache /// A base class that manages /// [ConfigurationName(VNCacheClient.CACHE_CONFIG_KEY)] - internal class FBMCacheClient : IGlobalCacheProvider, IAsyncBackgroundWork + internal class FBMCacheClient : VNCacheBase, IAsyncBackgroundWork { private const string LOG_NAME = "CLIENT"; private static readonly TimeSpan InitialDelay = TimeSpan.FromSeconds(10); @@ -60,6 +60,8 @@ namespace VNLib.Data.Caching.Providers.VNCache private readonly VnCacheClientConfig _config; private readonly ClusterNodeIndex _index; + private bool _isConnected; + /// /// The internal client /// @@ -68,7 +70,7 @@ namespace VNLib.Data.Caching.Providers.VNCache /// /// Gets a value that determines if the client is currently connected to a server /// - public bool IsConnected { get; private set; } + public override bool IsConnected => _isConnected; public FBMCacheClient(PluginBase plugin, IConfigScope config) : this( @@ -95,7 +97,7 @@ namespace VNLib.Data.Caching.Providers.VNCache } } - public FBMCacheClient(VnCacheClientConfig config, ILogProvider? debugLog) + public FBMCacheClient(VnCacheClientConfig config, ILogProvider? debugLog):base(config) { //Validate config (config as IOnConfigValidation).Validate(); @@ -103,7 +105,7 @@ namespace VNLib.Data.Caching.Providers.VNCache _config = config; //Init the client with default settings - FBMClientConfig conf = FBMDataCacheExtensions.GetDefaultConfig(MemoryUtil.Shared, config.MaxMessageSize!.Value, config.RequestTimeout, debugLog); + FBMClientConfig conf = FBMDataCacheExtensions.GetDefaultConfig(MemoryUtil.Shared, (int)config.MaxBlobSize, config.RequestTimeout, debugLog); Client = new(conf); @@ -183,7 +185,7 @@ namespace VNLib.Data.Caching.Providers.VNCache } //Set connection status flag - IsConnected = true; + _isConnected = true; //Wait for disconnect await Client.WaitForExitAsync(exitToken); @@ -213,7 +215,7 @@ namespace VNLib.Data.Caching.Providers.VNCache } finally { - IsConnected = false; + _isConnected = false; } //Loop again @@ -241,15 +243,7 @@ namespace VNLib.Data.Caching.Providers.VNCache /// - public virtual Task AddOrUpdateAsync(string key, string? newKey, T value, CancellationToken cancellation) - { - return !IsConnected - ? throw new InvalidOperationException("The underlying client is not connected to a cache node") - : Client!.AddOrUpdateObjectAsync(key, newKey, value, cancellation); - } - - /// - public virtual Task DeleteAsync(string key, CancellationToken cancellation) + public override Task DeleteAsync(string key, CancellationToken cancellation) { return !IsConnected ? throw new InvalidOperationException("The underlying client is not connected to a cache node") @@ -257,15 +251,7 @@ namespace VNLib.Data.Caching.Providers.VNCache } /// - public virtual Task GetAsync(string key, CancellationToken cancellation) - { - return !IsConnected - ? throw new InvalidOperationException("The underlying client is not connected to a cache node") - : Client!.GetObjectAsync(key, cancellation); - } - - /// - public virtual Task GetAsync(string key, ICacheObjectDeserializer deserializer, CancellationToken cancellation) + public override Task GetAsync(string key, ICacheObjectDeserializer deserializer, CancellationToken cancellation) { return !IsConnected ? throw new InvalidOperationException("The underlying client is not connected to a cache node") @@ -273,7 +259,7 @@ namespace VNLib.Data.Caching.Providers.VNCache } /// - public virtual Task AddOrUpdateAsync(string key, string? newKey, T value, ICacheObjectSerializer serialzer, CancellationToken cancellation) + public override Task AddOrUpdateAsync(string key, string? newKey, T value, ICacheObjectSerializer serialzer, CancellationToken cancellation) { return !IsConnected ? throw new InvalidOperationException("The underlying client is not connected to a cache node") @@ -281,7 +267,7 @@ namespace VNLib.Data.Caching.Providers.VNCache } /// - public virtual Task GetAsync(string key, ObjectDataSet callback, T state, CancellationToken cancellation) + public override Task GetAsync(string key, ObjectDataSet callback, T state, CancellationToken cancellation) { return !IsConnected ? throw new InvalidOperationException("The underlying client is not connected to a cache node") @@ -289,7 +275,7 @@ namespace VNLib.Data.Caching.Providers.VNCache } /// - public virtual Task AddOrUpdateAsync(string key, string? newKey, ObjectDataReader callback, T state, CancellationToken cancellation) + public override Task AddOrUpdateAsync(string key, string? newKey, ObjectDataReader callback, T state, CancellationToken cancellation) { return !IsConnected ? throw new InvalidOperationException("The underlying client is not connected to a cache node") @@ -297,7 +283,7 @@ namespace VNLib.Data.Caching.Providers.VNCache } /// - public object GetUnderlyingStore() => Client; //Client is the underlying "store" + public override object GetUnderlyingStore() => Client; //Client is the underlying "store" private sealed class AuthManager : ICacheAuthManager { -- cgit