aboutsummaryrefslogtreecommitdiff
path: root/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheExtensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheExtensions.cs')
-rw-r--r--lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheExtensions.cs28
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheExtensions.cs b/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheExtensions.cs
index ded89d2..1681256 100644
--- a/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheExtensions.cs
+++ b/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheExtensions.cs
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2023 Vaughn Nugent
+* Copyright (c) 2024 Vaughn Nugent
*
* Library: VNLib
* Package: VNLib.Data.Caching.ObjectCache
@@ -144,14 +144,14 @@ namespace VNLib.Data.Caching.ObjectCache
this IBlobCacheTable table,
string objectId,
string? alternateId,
- ObjectDataReader<T> bodyData,
+ ObjectDataGet<T> bodyData,
T state,
DateTime time,
CancellationToken cancellation = default)
{
-
- _ = table ?? throw new ArgumentNullException(nameof(table));
- _ = bodyData ?? throw new ArgumentNullException(nameof(bodyData));
+ ArgumentNullException.ThrowIfNull(table);
+ ArgumentNullException.ThrowIfNull(bodyData);
+ ArgumentException.ThrowIfNullOrWhiteSpace(objectId);
//See if an id change is required
if (string.IsNullOrWhiteSpace(alternateId))
@@ -252,11 +252,27 @@ namespace VNLib.Data.Caching.ObjectCache
/// <param name="objectId">The id of the object to delete</param>
/// <param name="cancellation">A token to cancel the async lock await</param>
/// <returns>A task that completes when the item has been deleted</returns>
- public static async ValueTask<bool> DeleteObjectAsync(this IBlobCacheTable table, string objectId, CancellationToken cancellation = default)
+ public static ValueTask<bool> DeleteObjectAsync(this IBlobCacheTable table, string objectId, CancellationToken cancellation = default)
{
+ ArgumentNullException.ThrowIfNull(table);
+
//Try to get the bucket that the id should belong to
IBlobCacheBucket bucket = table.GetBucket(objectId);
+ return DeleteObjectAsync(bucket, objectId, cancellation);
+ }
+
+ /// <summary>
+ /// Asynchronously deletes a previously stored item
+ /// </summary>
+ /// <param name="bucket"></param>
+ /// <param name="objectId">The id of the object to delete</param>
+ /// <param name="cancellation">A token to cancel the async lock await</param>
+ /// <returns>A task that completes when the item has been deleted</returns>
+ public static async ValueTask<bool> DeleteObjectAsync(this IBlobCacheBucket bucket, string objectId, CancellationToken cancellation = default)
+ {
+ ArgumentNullException.ThrowIfNull(bucket);
+
//Wait for the bucket
IBlobCache cache = await bucket.ManualWaitAsync(cancellation);