diff options
author | vnugent <public@vaughnnugent.com> | 2024-01-23 15:43:50 -0500 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-01-23 15:43:50 -0500 |
commit | a481d63f964a5d5204cac2e95141f37f9a28d573 (patch) | |
tree | 3e699bb0b1885355346c743b6d1bf2c8403dd731 /plugins/VNLib.Data.Caching.Providers.Redis | |
parent | c0e2a71b7b4081117d87c2c34c1b2afb8d511732 (diff) |
cache extension api tweaks
Diffstat (limited to 'plugins/VNLib.Data.Caching.Providers.Redis')
-rw-r--r-- | plugins/VNLib.Data.Caching.Providers.Redis/src/RedisClientCacheEntry.cs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/plugins/VNLib.Data.Caching.Providers.Redis/src/RedisClientCacheEntry.cs b/plugins/VNLib.Data.Caching.Providers.Redis/src/RedisClientCacheEntry.cs index f80c750..360be58 100644 --- a/plugins/VNLib.Data.Caching.Providers.Redis/src/RedisClientCacheEntry.cs +++ b/plugins/VNLib.Data.Caching.Providers.Redis/src/RedisClientCacheEntry.cs @@ -211,8 +211,8 @@ namespace VNLib.Data.Caching.Providers.Redis ///<inheritdoc/> public async Task AddOrUpdateAsync<T>(string key, string? newKey, T value, ICacheObjectSerializer serialzer, CancellationToken cancellation) { - _ = key ?? throw new ArgumentNullException(nameof(key)); - _ = serialzer ?? throw new ArgumentNullException(nameof(serialzer)); + ArgumentException.ThrowIfNullOrWhiteSpace(key); + ArgumentNullException.ThrowIfNull(serialzer); //Alloc update buffer using AddOrUpdateBuffer buffer = new(_defaultHeap, InitialWriterBufferSize, false); @@ -231,7 +231,7 @@ namespace VNLib.Data.Caching.Providers.Redis } ///<inheritdoc/> - public async Task AddOrUpdateAsync<T>(string key, string? newKey, ObjectDataReader<T> callback, T state, CancellationToken cancellation) + public async Task AddOrUpdateAsync<T>(string key, string? newKey, ObjectDataGet<T> callback, T state, CancellationToken cancellation) { /* * Because the redis database only allows ReadonlyMemory when @@ -253,7 +253,7 @@ namespace VNLib.Data.Caching.Providers.Redis await _database.KeyRenameAsync(key, newKey); } - static IMemoryOwner<byte> AllocAndCopy(ObjectDataReader<T> callback, T state, IUnmangedHeap heap, ref int length) + static IMemoryOwner<byte> AllocAndCopy(ObjectDataGet<T> callback, T state, IUnmangedHeap heap, ref int length) { //Get the buffer from the callback ReadOnlySpan<byte> data = callback(state); @@ -276,7 +276,8 @@ namespace VNLib.Data.Caching.Providers.Redis ///<inheritdoc/> public async Task<T?> GetAsync<T>(string key, ICacheObjectDeserializer deserializer, CancellationToken cancellation) { - _ = deserializer ?? throw new ArgumentNullException(nameof(deserializer)); + ArgumentException.ThrowIfNullOrWhiteSpace(key); + ArgumentNullException.ThrowIfNull(deserializer); //Try to get the value from the cache RedisValue value = await _database.StringGetAsync(key); @@ -293,7 +294,8 @@ namespace VNLib.Data.Caching.Providers.Redis ///<inheritdoc/> public async Task GetAsync<T>(string key, ObjectDataSet<T> callback, T state, CancellationToken cancellation) { - _ = callback ?? throw new ArgumentNullException(nameof(callback)); + ArgumentException.ThrowIfNullOrWhiteSpace(key); + ArgumentNullException.ThrowIfNull(callback); //Try to get the value from the cache RedisValue value = await _database.StringGetAsync(key); |