aboutsummaryrefslogtreecommitdiff
path: root/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VNLib.Plugins.Extensions.VNCache/src/DataModel')
-rw-r--r--lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs30
-rw-r--r--lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/ScopedCache.cs6
2 files changed, 36 insertions, 0 deletions
diff --git a/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs b/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs
index 79bb4fc..73baa4a 100644
--- a/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs
+++ b/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs
@@ -100,6 +100,7 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
KeyGen = keyGen;
}
+ ///<inheritdoc/>
public override Task AddOrUpdateAsync<T>(string key, string? newKey, T value, CancellationToken cancellation)
{
_ = key ?? throw new ArgumentNullException(nameof(key));
@@ -113,6 +114,7 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
return cache.AddOrUpdateAsync(primary, secondary, value, cancellation);
}
+ ///<inheritdoc/>
public override Task DeleteAsync(string key, CancellationToken cancellation)
{
_ = key ?? throw new ArgumentNullException(nameof(key));
@@ -121,6 +123,7 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
return cache.DeleteAsync(scoped, cancellation);
}
+ ///<inheritdoc/>
public override Task<T> GetAsync<T>(string key, CancellationToken cancellation)
{
_ = key ?? throw new ArgumentNullException(nameof(key));
@@ -131,6 +134,7 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
return cache.GetAsync<T?>(scoped, cancellation);
}
+ ///<inheritdoc/>
public override Task<T> GetAsync<T>(string key, ICacheObjectDeserialzer deserializer, CancellationToken cancellation)
{
_ = key ?? throw new ArgumentNullException(nameof(key));
@@ -141,6 +145,7 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
return cache.GetAsync<T?>(scoped, deserializer, cancellation);
}
+ ///<inheritdoc/>
public override Task AddOrUpdateAsync<T>(string key, string? newKey, T value, ICacheObjectSerialzer serialzer, CancellationToken cancellation)
{
_ = key ?? throw new ArgumentNullException(nameof(key));
@@ -153,6 +158,31 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
return cache.AddOrUpdateAsync(primary, secondary, value, serialzer, cancellation);
}
+
+ ///<inheritdoc/>
+ public override Task GetAsync(string key, IObjectData rawData, CancellationToken cancellation)
+ {
+ _ = key ?? throw new ArgumentNullException(nameof(key));
+
+ //Compute the key for the id
+ string scoped = KeyGen.ComputedKey(key);
+
+ return cache.GetAsync(scoped, rawData, cancellation);
+ }
+
+ ///<inheritdoc/>
+ public override Task AddOrUpdateAsync(string key, string? newKey, IObjectData rawData, ICacheObjectSerialzer serialzer, 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, rawData, serialzer, cancellation);
+ }
}
}
diff --git a/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/ScopedCache.cs b/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/ScopedCache.cs
index da2f78a..c26fd1a 100644
--- a/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/ScopedCache.cs
+++ b/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/ScopedCache.cs
@@ -60,5 +60,11 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
///<inheritdoc/>
public abstract Task AddOrUpdateAsync<T>(string key, string? newKey, T value, ICacheObjectSerialzer serialzer, CancellationToken cancellation);
+
+ ///<inheritdoc/>
+ public abstract Task GetAsync(string key, IObjectData rawData, CancellationToken cancellation);
+
+ ///<inheritdoc/>
+ public abstract Task AddOrUpdateAsync(string key, string? newKey, IObjectData rawData, ICacheObjectSerialzer serialzer, CancellationToken cancellation);
}
}