aboutsummaryrefslogtreecommitdiff
path: root/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.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 /lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs
parentd2d812213b99ee17f9433f81871b694c4053ff23 (diff)
Remove ambiguous default serializer functions
Diffstat (limited to 'lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs')
-rw-r--r--lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs49
1 files changed, 15 insertions, 34 deletions
diff --git a/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs b/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs
index befa14a..bf2fa2a 100644
--- a/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs
+++ b/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs
@@ -141,56 +141,37 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
private sealed class ScopedCacheImpl: ScopedCache
{
- private readonly IGlobalCacheProvider cache;
+ private readonly IGlobalCacheProvider Cache;
///<inheritdoc/>
public override bool IsConnected
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- get => cache.IsConnected;
+ get => Cache.IsConnected;
}
///<inheritdoc/>
protected override ICacheKeyGenerator KeyGen { get; }
- public ScopedCacheImpl(IGlobalCacheProvider cache, ICacheKeyGenerator keyGen)
- {
- this.cache = cache;
- KeyGen = keyGen;
- }
-
///<inheritdoc/>
- public override Task AddOrUpdateAsync<T>(string key, string? newKey, T value, CancellationToken cancellation)
- {
- _ = key ?? throw new ArgumentNullException(nameof(key));
-
- //Compute primary key from id
- string primary = KeyGen.ComputedKey(key);
-
- //If newkey exists, compute the secondary key
- string? secondary = newKey != null ? KeyGen.ComputedKey(newKey) : null;
-
- return cache.AddOrUpdateAsync(primary, secondary, value, cancellation);
- }
+ public override ICacheObjectDeserializer DefaultDeserializer => Cache.DefaultDeserializer;
///<inheritdoc/>
- public override Task<bool> DeleteAsync(string key, CancellationToken cancellation)
+ public override ICacheObjectSerializer DefaultSerializer => Cache.DefaultSerializer;
+
+ public ScopedCacheImpl(IGlobalCacheProvider cache, ICacheKeyGenerator keyGen)
{
- _ = key ?? throw new ArgumentNullException(nameof(key));
- //Compute the key for the id
- string scoped = KeyGen.ComputedKey(key);
- return cache.DeleteAsync(scoped, cancellation);
+ this.Cache = cache;
+ KeyGen = keyGen;
}
///<inheritdoc/>
- public override Task<T> GetAsync<T>(string key, CancellationToken cancellation)
+ public override Task<bool> DeleteAsync(string key, CancellationToken cancellation)
{
_ = key ?? throw new ArgumentNullException(nameof(key));
-
//Compute the key for the id
string scoped = KeyGen.ComputedKey(key);
-
- return cache.GetAsync<T?>(scoped, cancellation);
+ return Cache.DeleteAsync(scoped, cancellation);
}
///<inheritdoc/>
@@ -201,7 +182,7 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
//Compute the key for the id
string scoped = KeyGen.ComputedKey(key);
- return cache.GetAsync<T?>(scoped, deserializer, cancellation);
+ return Cache.GetAsync<T?>(scoped, deserializer, cancellation);
}
///<inheritdoc/>
@@ -215,7 +196,7 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
//If newkey exists, compute the secondary key
string? secondary = newKey != null ? KeyGen.ComputedKey(newKey) : null;
- return cache.AddOrUpdateAsync(primary, secondary, value, serialzer, cancellation);
+ return Cache.AddOrUpdateAsync(primary, secondary, value, serialzer, cancellation);
}
///<inheritdoc/>
@@ -226,7 +207,7 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
//Compute the key for the id
string scoped = KeyGen.ComputedKey(key);
- return cache.GetAsync(scoped, callback, state, cancellation);
+ return Cache.GetAsync(scoped, callback, state, cancellation);
}
///<inheritdoc/>
@@ -240,11 +221,11 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
//If newkey exists, compute the secondary key
string? secondary = newKey != null ? KeyGen.ComputedKey(newKey) : null;
- return cache.AddOrUpdateAsync(primary, secondary, callback, state, cancellation);
+ return Cache.AddOrUpdateAsync(primary, secondary, callback, state, cancellation);
}
///<inheritdoc/>
- public override object GetUnderlyingStore() => cache.GetUnderlyingStore();
+ public override object GetUnderlyingStore() => Cache.GetUnderlyingStore();
}
}