diff --git a/src/core/StackExchange.Redis.Extensions.Core/Abstractions/IRedisDatabase.cs b/src/core/StackExchange.Redis.Extensions.Core/Abstractions/IRedisDatabase.cs
index 75005e6..faab41f 100644
--- a/src/core/StackExchange.Redis.Extensions.Core/Abstractions/IRedisDatabase.cs
+++ b/src/core/StackExchange.Redis.Extensions.Core/Abstractions/IRedisDatabase.cs
@@ -16,12 +16,12 @@ public partial interface IRedisDatabase
///
/// Gets the instance of used be ICacheClient implementation
///
- IDatabase Database { get; }
+ public IDatabase Database { get; }
///
/// Gets the instance of
///
- ISerializer Serializer { get; }
+ public ISerializer Serializer { get; }
///
/// Verify that the specified cache key exists
@@ -29,7 +29,7 @@ public partial interface IRedisDatabase
/// The cache key.
/// Behaviour markers associated with a given command
/// True if the key is present into Redis. Othwerwise False
- Task ExistsAsync(string key, CommandFlags flag = CommandFlags.None);
+ public Task ExistsAsync(string key, CommandFlags flag = CommandFlags.None);
///
/// Removes the specified key from Redis Database
@@ -37,7 +37,7 @@ public partial interface IRedisDatabase
/// The cache key.
/// True if the key has removed. Othwerwise False
/// Behaviour markers associated with a given command
- Task RemoveAsync(string key, CommandFlags flag = CommandFlags.None);
+ public Task RemoveAsync(string key, CommandFlags flag = CommandFlags.None);
///
/// Removes all specified keys from Redis Database
@@ -45,7 +45,7 @@ public partial interface IRedisDatabase
/// The cache keys.
/// Behaviour markers associated with a given command
/// The numnber of items removed.
- Task RemoveAllAsync(string[] keys, CommandFlags flag = CommandFlags.None);
+ public Task RemoveAllAsync(string[] keys, CommandFlags flag = CommandFlags.None);
///
/// Get the object with the specified key from Redis database
@@ -54,7 +54,7 @@ public partial interface IRedisDatabase
/// The cache key.
/// Behaviour markers associated with a given command
/// Null if not present, otherwise the instance of T.
- Task GetAsync(string key, CommandFlags flag = CommandFlags.None);
+ public Task GetAsync(string key, CommandFlags flag = CommandFlags.None);
/// Get the object with the specified key from Redis database and update the expiry time
/// The type of the expected object.
@@ -62,7 +62,7 @@ public partial interface IRedisDatabase
/// Expiration time.
/// Behaviour markers associated with a given command
/// Null if not present, otherwise the instance of T.
- Task GetAsync(string key, DateTimeOffset expiresAt, CommandFlags flag = CommandFlags.None);
+ public Task GetAsync(string key, DateTimeOffset expiresAt, CommandFlags flag = CommandFlags.None);
///
/// Get the object with the specified key from Redis database and update the expiry time
@@ -74,7 +74,7 @@ public partial interface IRedisDatabase
///
/// Null if not present, otherwise the instance of T.
///
- Task GetAsync(string key, TimeSpan expiresIn, CommandFlags flag = CommandFlags.None);
+ public Task GetAsync(string key, TimeSpan expiresIn, CommandFlags flag = CommandFlags.None);
///
/// Adds the specified instance to the Redis database.
@@ -86,7 +86,7 @@ public partial interface IRedisDatabase
/// Behaviour markers associated with a given command
/// Tags
/// True if the object has been added. Otherwise false
- Task AddAsync(string key, T value, When when = When.Always, CommandFlags flag = CommandFlags.None, HashSet? tags = null);
+ public Task AddAsync(string key, T value, When when = When.Always, CommandFlags flag = CommandFlags.None, HashSet? tags = null);
///
/// Replaces the object with specified key into Redis database.
@@ -99,7 +99,7 @@ public partial interface IRedisDatabase
///
/// True if the object has been added. Otherwise false
///
- Task ReplaceAsync(string key, T value, When when = When.Always, CommandFlags flag = CommandFlags.None);
+ public Task ReplaceAsync(string key, T value, When when = When.Always, CommandFlags flag = CommandFlags.None);
///
/// Adds the specified instance to the Redis database.
@@ -114,7 +114,7 @@ public partial interface IRedisDatabase
///
/// True if the object has been added. Otherwise false
///
- Task AddAsync(string key, T value, DateTimeOffset expiresAt, When when = When.Always, CommandFlags flag = CommandFlags.None, HashSet? tags = null);
+ public Task AddAsync(string key, T value, DateTimeOffset expiresAt, When when = When.Always, CommandFlags flag = CommandFlags.None, HashSet? tags = null);
///
/// Replaces the object with specified key into Redis database.
@@ -128,7 +128,7 @@ public partial interface IRedisDatabase
///
/// True if the object has been added. Otherwise false
///
- Task ReplaceAsync(string key, T value, DateTimeOffset expiresAt, When when = When.Always, CommandFlags flag = CommandFlags.None);
+ public Task ReplaceAsync(string key, T value, DateTimeOffset expiresAt, When when = When.Always, CommandFlags flag = CommandFlags.None);
///
/// Adds the specified instance to the Redis database.
@@ -143,7 +143,7 @@ public partial interface IRedisDatabase
///
/// True if the object has been added. Otherwise false
///
- Task AddAsync(string key, T value, TimeSpan expiresIn, When when = When.Always, CommandFlags flag = CommandFlags.None, HashSet? tags = null);
+ public Task AddAsync(string key, T value, TimeSpan expiresIn, When when = When.Always, CommandFlags flag = CommandFlags.None, HashSet? tags = null);
///
/// Replaces the object with specified key into Redis database.
@@ -157,7 +157,7 @@ public partial interface IRedisDatabase
///
/// True if the object has been added. Otherwise false
///
- Task ReplaceAsync(string key, T value, TimeSpan expiresIn, When when = When.Always, CommandFlags flag = CommandFlags.None);
+ public Task ReplaceAsync(string key, T value, TimeSpan expiresIn, When when = When.Always, CommandFlags flag = CommandFlags.None);
///
/// Get the objects with the specified keys from Redis database with a single roundtrip
@@ -169,7 +169,7 @@ public partial interface IRedisDatabase
/// Empty list if there are no results, otherwise the instance of T.
/// If a cache key is not present on Redis the specified object into the returned Dictionary will be null
///
- Task> GetAllAsync(HashSet keys, CommandFlags flag = CommandFlags.None);
+ public Task> GetAllAsync(HashSet keys, CommandFlags flag = CommandFlags.None);
///
/// Get the objects with the specified keys from Redis database with one roundtrip
@@ -182,7 +182,7 @@ public partial interface IRedisDatabase
/// Empty list if there are no results, otherwise the instance of T.
/// If a cache key is not present on Redis the specified object into the returned Dictionary will be null
///
- Task> GetAllAsync(HashSet keys, DateTimeOffset expiresAt, CommandFlags flag = CommandFlags.None);
+ public Task> GetAllAsync(HashSet keys, DateTimeOffset expiresAt, CommandFlags flag = CommandFlags.None);
///
/// Get the objects with the specified keys from Redis database with one roundtrip
@@ -195,7 +195,7 @@ public partial interface IRedisDatabase
/// Empty list if there are no results, otherwise the instance of T.
/// If a cache key is not present on Redis the specified object into the returned Dictionary will be null
///
- Task> GetAllAsync(HashSet keys, TimeSpan expiresIn, CommandFlags flag = CommandFlags.None);
+ public Task> GetAllAsync(HashSet keys, TimeSpan expiresIn, CommandFlags flag = CommandFlags.None);
///
/// Add the objects with the specified keys to Redis database with a single roundtrip
@@ -205,7 +205,7 @@ public partial interface IRedisDatabase
/// Expiration time.
/// The condition (Always is the default value).
/// Behaviour markers associated with a given command
- Task AddAllAsync(Tuple[] items, DateTimeOffset expiresAt, When when = When.Always, CommandFlags flag = CommandFlags.None);
+ public Task AddAllAsync(Tuple[] items, DateTimeOffset expiresAt, When when = When.Always, CommandFlags flag = CommandFlags.None);
///
/// Add the objects with the specified keys to Redis database with a single roundtrip
@@ -214,7 +214,7 @@ public partial interface IRedisDatabase
/// The items.
/// The condition (Always is the default value).
/// Behaviour markers associated with a given command
- Task AddAllAsync(Tuple[] items, When when = When.Always, CommandFlags flag = CommandFlags.None);
+ public Task AddAllAsync(Tuple[] items, When when = When.Always, CommandFlags flag = CommandFlags.None);
///
/// Add the objects with the specified keys to Redis database with a single roundtrip
@@ -224,7 +224,7 @@ public partial interface IRedisDatabase
/// Time until expiration.
/// The condition (Always is the default value).
/// Behaviour markers associated with a given command
- Task AddAllAsync(Tuple[] items, TimeSpan expiresAt, When when = When.Always, CommandFlags flag = CommandFlags.None);
+ public Task AddAllAsync(Tuple[] items, TimeSpan expiresAt, When when = When.Always, CommandFlags flag = CommandFlags.None);
///
/// Run SADD command http://redis.io/commands/sadd
@@ -233,7 +233,7 @@ public partial interface IRedisDatabase
/// The cache key.
/// Name of the member.
/// Behaviour markers associated with a given command.
- Task SetAddAsync(string key, T item, CommandFlags flag = CommandFlags.None)
+ public Task SetAddAsync(string key, T item, CommandFlags flag = CommandFlags.None)
;
///
@@ -242,7 +242,7 @@ Task SetAddAsync(string key, T item, CommandFlags flag = CommandFlags.N
/// The type of the expected object.
/// The key of the set
/// Behaviour markers associated with a given command
- Task SetPopAsync(string key, CommandFlags flag = CommandFlags.None)
+ public Task SetPopAsync(string key, CommandFlags flag = CommandFlags.None)
;
///
@@ -252,7 +252,7 @@ Task SetAddAsync(string key, T item, CommandFlags flag = CommandFlags.N
/// The key of the set
/// The number of elements to return
/// Behaviour markers associated with a given command
- Task> SetPopAsync(string key, long count, CommandFlags flag = CommandFlags.None)
+ public Task> SetPopAsync(string key, long count, CommandFlags flag = CommandFlags.None)
;
///
@@ -262,7 +262,7 @@ Task SetAddAsync(string key, T item, CommandFlags flag = CommandFlags.N
/// The cache key.
/// The item to store into redis.
/// Behaviour markers associated with a given command.
- Task SetContainsAsync(string key, T item, CommandFlags flag = CommandFlags.None)
+ public Task SetContainsAsync(string key, T item, CommandFlags flag = CommandFlags.None)
;
///
@@ -272,7 +272,7 @@ Task SetContainsAsync(string key, T item, CommandFlags flag = CommandFl
/// The cache key.
/// Behaviour markers associated with a given command
/// Name of the member.
- Task SetAddAllAsync(string key, CommandFlags flag = CommandFlags.None, params T[] items);
+ public Task SetAddAllAsync(string key, CommandFlags flag = CommandFlags.None, params T[] items);
///
/// Run SADD command http://redis.io/commands/sadd
@@ -281,7 +281,7 @@ Task SetContainsAsync(string key, T item, CommandFlags flag = CommandFl
/// The cache key.
/// Behaviour markers associated with a given command
/// Name of the member.
- Task SetAddAllAsync(string key, CommandFlags flag = CommandFlags.None, params ReadOnlySpan items);
+ public Task SetAddAllAsync(string key, CommandFlags flag = CommandFlags.None, params ReadOnlySpan items);
///
/// Run SREM command http://redis.io/commands/srem"
@@ -290,7 +290,7 @@ Task SetContainsAsync(string key, T item, CommandFlags flag = CommandFl
/// The cache key.
/// The object to store into redis
/// Behaviour markers associated with a given command
- Task SetRemoveAsync(string key, T item, CommandFlags flag = CommandFlags.None);
+ public Task SetRemoveAsync(string key, T item, CommandFlags flag = CommandFlags.None);
///
/// Run SREM command http://redis.io/commands/srem
@@ -299,7 +299,7 @@ Task SetContainsAsync(string key, T item, CommandFlags flag = CommandFl
/// The cache key.
/// Behaviour markers associated with a given command
/// The items to store into Redis.
- Task SetRemoveAllAsync(string key, CommandFlags flag = CommandFlags.None, params T[] items);
+ public Task SetRemoveAllAsync(string key, CommandFlags flag = CommandFlags.None, params T[] items);
///
/// Run SREM command http://redis.io/commands/srem
@@ -308,14 +308,14 @@ Task SetContainsAsync(string key, T item, CommandFlags flag = CommandFl
/// The cache key.
/// Behaviour markers associated with a given command
/// The items to store into Redis.
- Task SetRemoveAllAsync(string key, CommandFlags flag = CommandFlags.None, params ReadOnlySpan items);
+ public Task SetRemoveAllAsync(string key, CommandFlags flag = CommandFlags.None, params ReadOnlySpan items);
///
/// Run SMEMBERS command see http://redis.io/commands/SMEMBERS
///
/// Name of the member.
/// Behaviour markers associated with a given command
- Task SetMemberAsync(string memberName, CommandFlags flag = CommandFlags.None);
+ public Task SetMemberAsync(string memberName, CommandFlags flag = CommandFlags.None);
///
/// Run SMEMBERS command see http://redis.io/commands/SMEMBERS
@@ -325,7 +325,7 @@ Task SetContainsAsync(string key, T item, CommandFlags flag = CommandFl
/// The key
/// Behaviour markers associated with a given command
/// An array of objects in the set
- Task SetMembersAsync(string key, CommandFlags flag = CommandFlags.None);
+ public Task SetMembersAsync(string key, CommandFlags flag = CommandFlags.None);
///
/// Searches the keys from Redis database
@@ -340,29 +340,29 @@ Task SetContainsAsync(string key, T item, CommandFlags flag = CommandFl
/// if you want to return all keys that end with "myCacheKey" uses "*myCacheKey"
///
/// A list of cache keys retrieved from Redis database
- Task> SearchKeysAsync(string pattern);
+ public Task> SearchKeysAsync(string pattern);
///
/// Flushes the database asynchronous.
///
- Task FlushDbAsync();
+ public Task FlushDbAsync();
///
/// Save the DB in background asynchronous.
///
- Task SaveAsync(SaveType saveType, CommandFlags flag = CommandFlags.None);
+ public Task SaveAsync(SaveType saveType, CommandFlags flag = CommandFlags.None);
///
/// Gets the information about redis.
/// More info see http://redis.io/commands/INFO
///
- Task> GetInfoAsync();
+ public Task> GetInfoAsync();
///
/// Gets the information about redis with category.
/// More info see http://redis.io/commands/INFO
///
- Task GetInfoCategorizedAsync();
+ public Task GetInfoCategorizedAsync();
///
/// Updates the expiry time of a redis cache object
@@ -371,7 +371,7 @@ Task SetContainsAsync(string key, T item, CommandFlags flag = CommandFl
/// The new expiry time of the object
/// Behaviour markers associated with a given command
/// True if the object is updated, false if the object does not exist
- Task UpdateExpiryAsync(string key, DateTimeOffset expiresAt, CommandFlags flag = CommandFlags.None);
+ public Task UpdateExpiryAsync(string key, DateTimeOffset expiresAt, CommandFlags flag = CommandFlags.None);
///
/// Updates the expiry time of a redis cache object
@@ -380,7 +380,7 @@ Task SetContainsAsync(string key, T item, CommandFlags flag = CommandFl
/// Time until the object will expire
/// Behaviour markers associated with a given command
/// True if the object is updated, false if the object does not exist
- Task UpdateExpiryAsync(string key, TimeSpan expiresIn, CommandFlags flag = CommandFlags.None);
+ public Task UpdateExpiryAsync(string key, TimeSpan expiresIn, CommandFlags flag = CommandFlags.None);
///
/// Updates the expiry time of a redis cache object
@@ -389,7 +389,7 @@ Task SetContainsAsync(string key, T item, CommandFlags flag = CommandFl
/// The new expiry time of the object
/// Behaviour markers associated with a given command
/// An array of type bool, where true if the object is updated and false if the object does not exist at the same index as the input keys
- Task> UpdateExpiryAllAsync(HashSet keys, DateTimeOffset expiresAt, CommandFlags flag = CommandFlags.None);
+ public Task> UpdateExpiryAllAsync(HashSet keys, DateTimeOffset expiresAt, CommandFlags flag = CommandFlags.None);
///
/// Updates the expiry time of a redis cache object
@@ -398,5 +398,5 @@ Task SetContainsAsync(string key, T item, CommandFlags flag = CommandFl
/// Time until the object will expire
/// Behaviour markers associated with a given command
/// An IDictionary object that contains the origional key and the result of the operation
- Task> UpdateExpiryAllAsync(HashSet keys, TimeSpan expiresIn, CommandFlags flag = CommandFlags.None);
+ public Task> UpdateExpiryAllAsync(HashSet keys, TimeSpan expiresIn, CommandFlags flag = CommandFlags.None);
}
diff --git a/src/core/StackExchange.Redis.Extensions.Core/Helpers/ExceptionThrowHelper.cs b/src/core/StackExchange.Redis.Extensions.Core/Helpers/ExceptionThrowHelper.cs
index b7d72a6..39af461 100644
--- a/src/core/StackExchange.Redis.Extensions.Core/Helpers/ExceptionThrowHelper.cs
+++ b/src/core/StackExchange.Redis.Extensions.Core/Helpers/ExceptionThrowHelper.cs
@@ -6,12 +6,6 @@
namespace StackExchange.Redis.Extensions.Core.Helpers;
internal static class ExceptionThrowHelper
{
- public static void ThrowIfSpanEmpty(ReadOnlySpan argument, string paramName)
- {
- if (argument.IsEmpty)
- throw new ArgumentException("The argument cannot be empty.", paramName);
- }
-
public static void ThrowIfExistsNullElement(ReadOnlySpan argument, string paramName)
{
if (argument.Any(x => x is null))
diff --git a/src/core/StackExchange.Redis.Extensions.Core/Implementations/RedisDatabase.Hash.cs b/src/core/StackExchange.Redis.Extensions.Core/Implementations/RedisDatabase.Hash.cs
index 4a09354..6f6f901 100644
--- a/src/core/StackExchange.Redis.Extensions.Core/Implementations/RedisDatabase.Hash.cs
+++ b/src/core/StackExchange.Redis.Extensions.Core/Implementations/RedisDatabase.Hash.cs
@@ -1,7 +1,6 @@
// Copyright (c) Ugo Lattanzi. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.
using System;
-using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
@@ -49,7 +48,7 @@ public Task HashExistsAsync(string hashKey, string key, CommandFlags flag
public async Task> HashGetAsync(string hashKey, string[] keys, CommandFlags flag = CommandFlags.None)
{
#if NET6_0_OR_GREATER
- var concurrent = new ConcurrentDictionary();
+ var concurrent = new System.Collections.Concurrent.ConcurrentDictionary();
await Parallel.ForEachAsync(keys, async (key, _) =>
{
@@ -92,7 +91,7 @@ await Parallel.ForEachAsync(keys, async (key, _) =>
var dictionary = new Dictionary();
- var redisValues = ((RedisValue[]?)data);
+ var redisValues = (RedisValue[]?)data;
ref var searchSpaceRedisValue = ref MemoryMarshal.GetReference(redisValues.AsSpan());
@@ -103,12 +102,12 @@ await Parallel.ForEachAsync(keys, async (key, _) =>
{
ref var key = ref Unsafe.Add(ref searchSpaceRedisValue, i);
- if (key.HasValue == false)
+ if (!key.HasValue)
continue;
var redisValue = redisValues[i + 1];
- if (redisValue.HasValue == false)
+ if (!redisValue.HasValue)
continue;
#pragma warning disable CS8604 // Possible null reference argument.
diff --git a/src/core/StackExchange.Redis.Extensions.Core/Implementations/RedisDatabase.List.cs b/src/core/StackExchange.Redis.Extensions.Core/Implementations/RedisDatabase.List.cs
index d9a72a5..24f39fe 100644
--- a/src/core/StackExchange.Redis.Extensions.Core/Implementations/RedisDatabase.List.cs
+++ b/src/core/StackExchange.Redis.Extensions.Core/Implementations/RedisDatabase.List.cs
@@ -12,11 +12,16 @@ public partial class RedisDatabase
///
public Task ListAddToLeftAsync(string key, T item, When when = When.Always, CommandFlags flag = CommandFlags.None)
{
+#if NET8_0_OR_GREATER
+ ArgumentException.ThrowIfNullOrEmpty(key);
+ ArgumentNullException.ThrowIfNull(item);
+#else
if (string.IsNullOrEmpty(key))
throw new ArgumentException("key cannot be empty.", nameof(key));
if (item == null)
throw new ArgumentNullException(nameof(item), "item cannot be null.");
+#endif
var serializedItem = Serializer.Serialize(item);
@@ -26,11 +31,16 @@ public Task ListAddToLeftAsync(string key, T item, When when = When.Alw
///
public Task ListAddToLeftAsync(string key, T[] items, CommandFlags flag = CommandFlags.None)
{
+#if NET8_0_OR_GREATER
+ ArgumentException.ThrowIfNullOrEmpty(key);
+ ArgumentNullException.ThrowIfNull(items);
+#else
if (string.IsNullOrEmpty(key))
throw new ArgumentException("key cannot be empty.", nameof(key));
if (items == null)
throw new ArgumentNullException(nameof(items), "item cannot be null.");
+#endif
var serializedItems = items.ToFastArray(item => (RedisValue)Serializer.Serialize(item));
@@ -40,8 +50,12 @@ public Task ListAddToLeftAsync(string key, T[] items, CommandFlags flag
///
public async Task ListGetFromRightAsync(string key, CommandFlags flag = CommandFlags.None)
{
+#if NET8_0_OR_GREATER
+ ArgumentException.ThrowIfNullOrEmpty(key);
+#else
if (string.IsNullOrEmpty(key))
throw new ArgumentException("key cannot be empty.", nameof(key));
+#endif
var item = await Database.ListRightPopAsync(key, flag).ConfigureAwait(false);
diff --git a/src/core/StackExchange.Redis.Extensions.Core/Implementations/RedisDatabase.PubSub.cs b/src/core/StackExchange.Redis.Extensions.Core/Implementations/RedisDatabase.PubSub.cs
index 2b0c691..4a76afe 100644
--- a/src/core/StackExchange.Redis.Extensions.Core/Implementations/RedisDatabase.PubSub.cs
+++ b/src/core/StackExchange.Redis.Extensions.Core/Implementations/RedisDatabase.PubSub.cs
@@ -20,8 +20,12 @@ public Task PublishAsync(RedisChannel channel, T message, CommandFlags
///
public Task SubscribeAsync(RedisChannel channel, Func handler, CommandFlags flag = CommandFlags.None)
{
+#if NET8_0_OR_GREATER
+ ArgumentNullException.ThrowIfNull(handler);
+#else
if (handler == null)
throw new ArgumentNullException(nameof(handler));
+#endif
var sub = connectionPoolManager.GetConnection().GetSubscriber();
@@ -34,8 +38,12 @@ void Handler(RedisChannel redisChannel, RedisValue value) =>
///
public Task UnsubscribeAsync(RedisChannel channel, Func handler, CommandFlags flag = CommandFlags.None)
{
+#if NET8_0_OR_GREATER
+ ArgumentNullException.ThrowIfNull(handler);
+#else
if (handler == null)
throw new ArgumentNullException(nameof(handler));
+#endif
var sub = connectionPoolManager.GetConnection().GetSubscriber();
return sub.UnsubscribeAsync(channel, (_, value) => handler(Serializer.Deserialize(value)), flag);
diff --git a/src/core/StackExchange.Redis.Extensions.Core/Implementations/RedisDatabase.cs b/src/core/StackExchange.Redis.Extensions.Core/Implementations/RedisDatabase.cs
index 8ad79c8..f80f690 100644
--- a/src/core/StackExchange.Redis.Extensions.Core/Implementations/RedisDatabase.cs
+++ b/src/core/StackExchange.Redis.Extensions.Core/Implementations/RedisDatabase.cs
@@ -265,11 +265,16 @@ public async Task AddAllAsync(Tuple[] items, TimeSpan expire
///
public Task SetAddAsync(string key, T item, CommandFlags flag = CommandFlags.None)
{
+#if NET8_0_OR_GREATER
+ ArgumentException.ThrowIfNullOrEmpty(key);
+ ArgumentNullException.ThrowIfNull(item);
+#else
if (string.IsNullOrEmpty(key))
throw new ArgumentException("key cannot be empty.", nameof(key));
if (item == null)
throw new ArgumentNullException(nameof(item), "item cannot be null.");
+#endif
var serializedObject = Serializer.Serialize(item);
@@ -279,8 +284,12 @@ public Task SetAddAsync(string key, T item, CommandFlags flag = Command
///
public async Task SetPopAsync(string key, CommandFlags flag = CommandFlags.None)
{
+#if NET8_0_OR_GREATER
+ ArgumentException.ThrowIfNullOrEmpty(key);
+#else
if (string.IsNullOrEmpty(key))
throw new ArgumentException("key cannot be empty.", nameof(key));
+#endif
var item = await Database.SetPopAsync(key, flag).ConfigureAwait(false);
@@ -292,8 +301,12 @@ public Task SetAddAsync(string key, T item, CommandFlags flag = Command
///
public async Task> SetPopAsync(string key, long count, CommandFlags flag = CommandFlags.None)
{
+#if NET8_0_OR_GREATER
+ ArgumentException.ThrowIfNullOrEmpty(key);
+#else
if (string.IsNullOrEmpty(key))
throw new ArgumentException("key cannot be empty.", nameof(key));
+#endif
var items = await Database.SetPopAsync(key, count, flag).ConfigureAwait(false);
@@ -303,11 +316,16 @@ public Task SetAddAsync(string key, T item, CommandFlags flag = Command
///
public Task SetContainsAsync(string key, T item, CommandFlags flag = CommandFlags.None)
{
+#if NET8_0_OR_GREATER
+ ArgumentException.ThrowIfNullOrEmpty(key);
+ ArgumentNullException.ThrowIfNull(item);
+#else
if (string.IsNullOrEmpty(key))
throw new ArgumentException("key cannot be empty.", nameof(key));
if (item == null)
throw new ArgumentNullException(nameof(item), "item cannot be null.");
+#endif
var serializedObject = Serializer.Serialize(item);
@@ -317,11 +335,16 @@ public Task SetContainsAsync(string key, T item, CommandFlags flag = Co
///