aboutsummaryrefslogtreecommitdiff
path: root/plugins/VNLib.Data.Caching.Providers.VNCache/src/VNCacheBase.cs
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-11-02 21:35:08 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2023-11-02 21:35:08 -0400
commit718bed529299ea9aad03d848b835cbda1854be34 (patch)
tree5efa103be60cc512ba049bc5f9880d96faedf676 /plugins/VNLib.Data.Caching.Providers.VNCache/src/VNCacheBase.cs
parentd2d812213b99ee17f9433f81871b694c4053ff23 (diff)
Remove ambiguous default serializer functions
Diffstat (limited to 'plugins/VNLib.Data.Caching.Providers.VNCache/src/VNCacheBase.cs')
-rw-r--r--plugins/VNLib.Data.Caching.Providers.VNCache/src/VNCacheBase.cs66
1 files changed, 66 insertions, 0 deletions
diff --git a/plugins/VNLib.Data.Caching.Providers.VNCache/src/VNCacheBase.cs b/plugins/VNLib.Data.Caching.Providers.VNCache/src/VNCacheBase.cs
new file mode 100644
index 0000000..fde2e44
--- /dev/null
+++ b/plugins/VNLib.Data.Caching.Providers.VNCache/src/VNCacheBase.cs
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2023 Vaughn Nugent
+*
+* Library: VNLib
+* Package: VNLib.Data.Caching.Providers.VNCache
+* File: VNCacheBase.cs
+*
+* VNCacheBase.cs is part of VNLib.Data.Caching.Providers.VNCache
+* which is part of the larger VNLib collection of libraries and utilities.
+*
+* VNLib.Data.Caching.Providers.VNCache is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as
+* published by the Free Software Foundation, either version 3 of the
+* License, or (at your option) any later version.
+*
+* VNLib.Data.Caching.Providers.VNCache is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with this program. If not, see https://www.gnu.org/licenses/.
+*/
+
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace VNLib.Data.Caching.Providers.VNCache
+{
+ internal abstract class VNCacheBase : IGlobalCacheProvider
+ {
+ ///<inheritdoc/>
+ public abstract bool IsConnected { get; }
+
+ ///<inheritdoc/>
+ public virtual ICacheObjectDeserializer DefaultDeserializer { get; }
+
+ ///<inheritdoc/>
+ public virtual ICacheObjectSerializer DefaultSerializer { get; }
+
+ protected VNCacheBase(VNCacheConfig config)
+ {
+ //Set default serializers
+ DefaultDeserializer = config.CacheObjectDeserializer ?? new JsonCacheObjectSerializer();
+ DefaultSerializer = config.CacheObjectSerializer ?? new JsonCacheObjectSerializer();
+ }
+
+ ///<inheritdoc/>
+ public abstract Task AddOrUpdateAsync<T>(string key, string? newKey, T value, ICacheObjectSerializer serialzer, CancellationToken cancellation);
+
+ ///<inheritdoc/>
+ public abstract Task AddOrUpdateAsync<T>(string key, string? newKey, ObjectDataReader<T> callback, T state, CancellationToken cancellation);
+
+ ///<inheritdoc/>
+ public abstract Task<bool> DeleteAsync(string key, CancellationToken cancellation);
+
+ ///<inheritdoc/>
+ public abstract Task<T?> GetAsync<T>(string key, ICacheObjectDeserializer deserializer, CancellationToken cancellation);
+
+ ///<inheritdoc/>
+ public abstract Task GetAsync<T>(string key, ObjectDataSet<T> callback, T state, CancellationToken cancellation);
+
+ ///<inheritdoc/>
+ public abstract object GetUnderlyingStore();
+ }
+} \ No newline at end of file