aboutsummaryrefslogtreecommitdiff
path: root/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-02-14 14:23:53 -0500
committerLibravatar vnugent <public@vaughnnugent.com>2024-02-14 14:23:53 -0500
commit6b87785026ca57d6f41cff87ddbd066362f3cacc (patch)
tree74cddbca5eebcec7948e706bd7b742b19e55eeb6 /lib/VNLib.Plugins.Extensions.VNCache/src/DataModel
parentc0e2a71b7b4081117d87c2c34c1b2afb8d511732 (diff)
Squashed commit of the following:
commit 456ead9bc8b0f61357bae93152ad0403c4940101 Author: vnugent <public@vaughnnugent.com> Date: Tue Feb 13 14:46:35 2024 -0500 fix: #1 shared cluster index on linux & latested core updates commit a481d63f964a5d5204cac2e95141f37f9a28d573 Author: vnugent <public@vaughnnugent.com> Date: Tue Jan 23 15:43:50 2024 -0500 cache extension api tweaks
Diffstat (limited to 'lib/VNLib.Plugins.Extensions.VNCache/src/DataModel')
-rw-r--r--lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs21
-rw-r--r--lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/ScopedCache.cs4
2 files changed, 13 insertions, 12 deletions
diff --git a/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs b/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs
index 562c220..6b39580 100644
--- a/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs
+++ b/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/EntityCacheExtensions.cs
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2023 Vaughn Nugent
+* Copyright (c) 2024 Vaughn Nugent
*
* Library: VNLib
* Package: VNLib.Plugins.Extensions.VNCache
@@ -164,12 +164,13 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
/// <param name="factory">The factory callback function to produce a value when a cache miss occurs</param>
/// <param name="cancellation">A token to cancel the operation</param>
/// <returns>A task that completes by returning the entity</returns>
+ /// <exception cref="ArgumentException"></exception>
/// <exception cref="ArgumentNullException"></exception>
public static async Task<T?> GetOrLoadAsync<T>(this IEntityCache<T> cache, string id, Func<string, CancellationToken, Task<T?>> factory, CancellationToken cancellation = default) where T : class
{
- _ = cache ?? throw new ArgumentNullException(nameof(cache));
- _ = id ?? throw new ArgumentNullException(nameof(id));
- _ = factory ?? throw new ArgumentNullException(nameof(factory));
+ ArgumentNullException.ThrowIfNull(cache);
+ ArgumentNullException.ThrowIfNull(factory);
+ ArgumentException.ThrowIfNullOrWhiteSpace(id);
//try to load the value from cache
T? record = await cache.GetAsync(id, cancellation);
@@ -241,7 +242,7 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
///<inheritdoc/>
public override Task<bool> DeleteAsync(string key, CancellationToken cancellation)
{
- _ = key ?? throw new ArgumentNullException(nameof(key));
+ ArgumentException.ThrowIfNullOrWhiteSpace(key);
//Compute the key for the id
string scoped = KeyGen.ComputedKey(key);
return Cache.DeleteAsync(scoped, cancellation);
@@ -250,7 +251,7 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
///<inheritdoc/>
public override Task<T> GetAsync<T>(string key, ICacheObjectDeserializer deserializer, CancellationToken cancellation)
{
- _ = key ?? throw new ArgumentNullException(nameof(key));
+ ArgumentException.ThrowIfNullOrWhiteSpace(key);
//Compute the key for the id
string scoped = KeyGen.ComputedKey(key);
@@ -261,7 +262,7 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
///<inheritdoc/>
public override Task AddOrUpdateAsync<T>(string key, string? newKey, T value, ICacheObjectSerializer serialzer, CancellationToken cancellation)
{
- _ = key ?? throw new ArgumentNullException(nameof(key));
+ ArgumentException.ThrowIfNullOrWhiteSpace(key);
//Compute primary key from id
string primary = KeyGen.ComputedKey(key);
@@ -275,7 +276,7 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
///<inheritdoc/>
public override Task GetAsync<T>(string key, ObjectDataSet<T> callback, T state, CancellationToken cancellation)
{
- _ = key ?? throw new ArgumentNullException(nameof(key));
+ ArgumentException.ThrowIfNullOrWhiteSpace(key);
//Compute the key for the id
string scoped = KeyGen.ComputedKey(key);
@@ -284,9 +285,9 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
}
///<inheritdoc/>
- public override Task AddOrUpdateAsync<T>(string key, string? newKey, ObjectDataReader<T> callback, T state, CancellationToken cancellation)
+ public override Task AddOrUpdateAsync<T>(string key, string? newKey, ObjectDataGet<T> callback, T state, CancellationToken cancellation)
{
- _ = key ?? throw new ArgumentNullException(nameof(key));
+ ArgumentException.ThrowIfNullOrWhiteSpace(key);
//Compute primary key from id
string primary = KeyGen.ComputedKey(key);
diff --git a/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/ScopedCache.cs b/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/ScopedCache.cs
index 545e194..5107dea 100644
--- a/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/ScopedCache.cs
+++ b/lib/VNLib.Plugins.Extensions.VNCache/src/DataModel/ScopedCache.cs
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2023 Vaughn Nugent
+* Copyright (c) 2024 Vaughn Nugent
*
* Library: VNLib
* Package: VNLib.Plugins.Extensions.VNCache
@@ -65,7 +65,7 @@ namespace VNLib.Plugins.Extensions.VNCache.DataModel
public abstract Task GetAsync<T>(string key, ObjectDataSet<T> callback, T state, CancellationToken cancellation);
///<inheritdoc/>
- public abstract Task AddOrUpdateAsync<T>(string key, string? newKey, ObjectDataReader<T> callback, T state, CancellationToken cancellation);
+ public abstract Task AddOrUpdateAsync<T>(string key, string? newKey, ObjectDataGet<T> callback, T state, CancellationToken cancellation);
///<inheritdoc/>
public abstract object GetUnderlyingStore();