diff --git a/src/StackExchange.Redis.Extensions.AspNetCore/StackExchange.Redis.Extensions.AspNetCore.csproj b/src/StackExchange.Redis.Extensions.AspNetCore/StackExchange.Redis.Extensions.AspNetCore.csproj
index cbab23c0..b6975e77 100644
--- a/src/StackExchange.Redis.Extensions.AspNetCore/StackExchange.Redis.Extensions.AspNetCore.csproj
+++ b/src/StackExchange.Redis.Extensions.AspNetCore/StackExchange.Redis.Extensions.AspNetCore.csproj
@@ -5,7 +5,7 @@
StackExchange.Redis.Extensions.AspNetCore is a library that has a set of extensions method fpr ASP.NET Core.
StackExchange.Redis.Extensions.AspNetCore is a library that has a set of extensions method fpr ASP.NET Core with the scope to simply the library configuration into the dependency injection
StackExchange.Redis.Extensions.AspNetCore is a library that has a set of extensions method fpr ASP.NET Core
- 5.1.0
+ 5.1.1
Ugo Lattanzi
Ugo Lattanzi
diff --git a/src/StackExchange.Redis.Extensions.Binary/StackExchange.Redis.Extensions.Binary.csproj b/src/StackExchange.Redis.Extensions.Binary/StackExchange.Redis.Extensions.Binary.csproj
index 7a74130a..156b47da 100644
--- a/src/StackExchange.Redis.Extensions.Binary/StackExchange.Redis.Extensions.Binary.csproj
+++ b/src/StackExchange.Redis.Extensions.Binary/StackExchange.Redis.Extensions.Binary.csproj
@@ -8,7 +8,7 @@
StackExchange.Redis.Extensions is a library that extends StackExchange.Redis allowing you a set of functionality needed by common applications.
This implementation is based on Microsoft's BinarySerializer
- 5.1.0
+ 5.1.1
Ugo Lattanzi
Ugo Lattanzi
diff --git a/src/StackExchange.Redis.Extensions.Core/Abstractions/IRedisDatabase.cs b/src/StackExchange.Redis.Extensions.Core/Abstractions/IRedisDatabase.cs
index 098c9177..7a428622 100644
--- a/src/StackExchange.Redis.Extensions.Core/Abstractions/IRedisDatabase.cs
+++ b/src/StackExchange.Redis.Extensions.Core/Abstractions/IRedisDatabase.cs
@@ -23,6 +23,7 @@ public interface IRedisDatabase
/// The cache key.
/// Behaviour markers associated with a given command
/// True if the key is present into Redis. Othwerwise False
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool Exists(string key, CommandFlags flag = CommandFlags.None);
///
@@ -39,6 +40,7 @@ public interface IRedisDatabase
/// The key.
/// Behaviour markers associated with a given command
/// True if the key has removed. Othwerwise False
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool Remove(string key, CommandFlags flag = CommandFlags.None);
///
@@ -54,6 +56,7 @@ public interface IRedisDatabase
///
/// The key.
/// Behaviour markers associated with a given command
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
void RemoveAll(IEnumerable keys, CommandFlags flag = CommandFlags.None);
///
@@ -70,6 +73,7 @@ public interface IRedisDatabase
/// The cache key.
/// Behaviour markers associated with a given command
/// Null if not present, otherwise the instance of T.
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
T Get(string key, CommandFlags flag = CommandFlags.None);
///
@@ -80,6 +84,7 @@ public interface IRedisDatabase
/// Expiration time.
/// Behaviour markers associated with a given command
/// Null if not present, otherwise the instance of T.
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
T Get(string key, DateTimeOffset expiresAt, CommandFlags flag = CommandFlags.None);
///
@@ -92,6 +97,7 @@ public interface IRedisDatabase
///
/// Null if not present, otherwise the instance of T.
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
T Get(string key, TimeSpan expiresIn, CommandFlags flag = CommandFlags.None);
///
@@ -131,6 +137,7 @@ public interface IRedisDatabase
/// The instance of T.
/// Behaviour markers associated with a given command
/// True if the object has been added. Otherwise false
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool Add(string key, T value, When when = When.Always, CommandFlags flag = CommandFlags.None);
///
@@ -153,6 +160,7 @@ public interface IRedisDatabase
///
/// True if the object has been added. Otherwise false
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool Replace(string key, T value, When when = When.Always, CommandFlags flag = CommandFlags.None);
///
@@ -178,6 +186,7 @@ public interface IRedisDatabase
///
/// True if the object has been added. Otherwise false
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool Add(string key, T value, DateTimeOffset expiresAt, When when = When.Always, CommandFlags flag = CommandFlags.None);
///
@@ -204,6 +213,7 @@ public interface IRedisDatabase
///
/// True if the object has been added. Otherwise false
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool Replace(string key, T value, DateTimeOffset expiresAt, When when = When.Always, CommandFlags flag = CommandFlags.None);
///
@@ -230,6 +240,7 @@ public interface IRedisDatabase
///
/// True if the object has been added. Otherwise false
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool Add(string key, T value, TimeSpan expiresIn, When when = When.Always, CommandFlags flag = CommandFlags.None);
///
@@ -256,6 +267,7 @@ public interface IRedisDatabase
///
/// True if the object has been added. Otherwise false
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool Replace(string key, T value, TimeSpan expiresIn, When when = When.Always, CommandFlags flag = CommandFlags.None);
///
@@ -280,6 +292,7 @@ public 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
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
IDictionary GetAll(IEnumerable keys);
///
@@ -292,6 +305,7 @@ public 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
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
IDictionary GetAll(IEnumerable keys, DateTimeOffset expiresAt);
///
@@ -304,6 +318,7 @@ public 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
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
IDictionary GetAll(IEnumerable keys, TimeSpan expiresIn);
///
@@ -346,6 +361,7 @@ public interface IRedisDatabase
///
/// The type of the expected object
/// The items.
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool AddAll(IList> items, When when = When.Always, CommandFlags flag = CommandFlags.None);
///
@@ -361,6 +377,7 @@ public interface IRedisDatabase
/// The type of the expected object
/// The items.
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool AddAll(IList> items, DateTimeOffset expiresAt, When when = When.Always, CommandFlags flag = CommandFlags.None);
///
@@ -377,6 +394,7 @@ public interface IRedisDatabase
/// The type of the expected object
/// The items.
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool AddAll(IList> items, TimeSpan expiresOn, When when = When.Always, CommandFlags flag = CommandFlags.None);
///
@@ -392,6 +410,7 @@ public interface IRedisDatabase
///
/// Name of the member.
/// The key.
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool SetAdd(string key, T item, CommandFlags flag = CommandFlags.None) where T : class;
///
@@ -406,6 +425,7 @@ public interface IRedisDatabase
///
/// Name of the member.
/// The key.
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
long SetAddAll(string key, CommandFlags flag = CommandFlags.None, params T[] items) where T : class;
///
@@ -421,6 +441,7 @@ public interface IRedisDatabase
///
///
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool SetRemove(string key, T item, CommandFlags flag = CommandFlags.None) where T : class;
///
@@ -437,6 +458,7 @@ public interface IRedisDatabase
///
///
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
long SetRemoveAll(string key, CommandFlags flag = CommandFlags.None, params T[] items) where T : class;
///
@@ -451,6 +473,7 @@ public interface IRedisDatabase
/// Run SMEMBERS command http://redis.io/commands/SMEMBERS
///
/// Name of the member.
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
string[] SetMember(string memberName, CommandFlags flag = CommandFlags.None);
///
@@ -466,6 +489,7 @@ public interface IRedisDatabase
/// The type of the expected objects in the set
/// The key
/// An array of objects in the set
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
IEnumerable SetMembers(string key, CommandFlags flag = CommandFlags.None);
///
@@ -490,6 +514,7 @@ public interface IRedisDatabase
/// if you want to return all keys that end with "myCacheKey" uses "*myCacheKey"
///
/// A list of cache keys retrieved from Redis database
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
IEnumerable SearchKeys(string pattern);
///
@@ -510,6 +535,7 @@ public interface IRedisDatabase
///
/// Flushes the database.
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
void FlushDb();
///
@@ -521,6 +547,7 @@ public interface IRedisDatabase
///
/// Save the DB in background.
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
void Save(SaveType saveType, CommandFlags flag = CommandFlags.None);
///
@@ -532,6 +559,7 @@ public interface IRedisDatabase
/// Gets the information about redis.
/// More info see http://redis.io/commands/INFO
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
Dictionary GetInfo();
///
@@ -543,6 +571,7 @@ public interface IRedisDatabase
///
/// Publishes a message to a channel.
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
long Publish(RedisChannel channel, T message, CommandFlags flag = CommandFlags.None);
///
@@ -553,6 +582,7 @@ public interface IRedisDatabase
///
/// Registers a callback handler to process messages published to a channel.
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
void Subscribe(RedisChannel channel, Action handler, CommandFlags flag = CommandFlags.None);
///
@@ -563,6 +593,7 @@ public interface IRedisDatabase
///
/// Unregisters a callback handler to process messages published to a channel.
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
void Unsubscribe(RedisChannel channel, Action handler, CommandFlags flag = CommandFlags.None);
///
@@ -573,6 +604,7 @@ public interface IRedisDatabase
///
/// Unregisters all callback handlers on a channel.
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
void UnsubscribeAll(CommandFlags flag = CommandFlags.None);
///
@@ -592,6 +624,7 @@ public interface IRedisDatabase
///
/// http://redis.io/commands/lpush
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
long ListAddToLeft(string key, T item, When when = When.Always, CommandFlags flag = CommandFlags.None) where T : class;
///
@@ -612,6 +645,7 @@ public interface IRedisDatabase
///
/// http://redis.io/commands/rpop
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
T ListGetFromRight(string key, CommandFlags flag = CommandFlags.None) where T : class;
///
@@ -639,6 +673,7 @@ public interface IRedisDatabase
/// If key is deleted returns true.
/// If key does not exist, it is treated as an empty hash and this command returns false.
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool HashDelete(string hashKey, string key, CommandFlags flag = CommandFlags.None);
///
@@ -653,6 +688,7 @@ public interface IRedisDatabase
///
/// Command execution flag
/// Tthe number of fields that were removed from the hash, not including specified but non existing fields.
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
long HashDelete(string hashKey, IEnumerable keys, CommandFlags flag = CommandFlags.None);
///
@@ -665,6 +701,7 @@ public interface IRedisDatabase
/// The key of the field in the hash
/// Command execution flag
/// Returns if field is an existing field in the hash stored at key.
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool HashExists(string hashKey, string key, CommandFlags flag = CommandFlags.None);
///
@@ -678,6 +715,7 @@ public interface IRedisDatabase
/// Key of the entry
/// Command execution flag
/// the value associated with field, or nil when field is not present in the hash or key does not exist.
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
T HashGet(string hashKey, string key, CommandFlags flag = CommandFlags.None);
///
@@ -693,6 +731,7 @@ public interface IRedisDatabase
///
/// Command execution flag
/// list of values associated with the given fields, in the same order as they are requested.
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
Dictionary HashGet(string hashKey, IEnumerable keys, CommandFlags flag = CommandFlags.None);
///
@@ -705,6 +744,7 @@ public interface IRedisDatabase
/// Key of the hash
/// Command execution flag
/// list of fields and their values stored in the hash, or an empty list when key does not exist.
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
Dictionary HashGetAll(string hashKey, CommandFlags flag = CommandFlags.None);
///
@@ -719,6 +759,7 @@ public interface IRedisDatabase
/// Key of the entry
/// Command execution flag
/// the value at field after the increment operation
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
long HashIncerementBy(string hashKey, string key, long value, CommandFlags flag = CommandFlags.None);
///
@@ -739,6 +780,7 @@ public interface IRedisDatabase
/// Key of the entry
/// Command execution flag
/// the value at field after the increment operation
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
double HashIncerementBy(string hashKey, string key, double value, CommandFlags flag = CommandFlags.None);
///
@@ -750,6 +792,7 @@ public interface IRedisDatabase
/// Key of the hash
/// Command execution flag
/// list of fields in the hash, or an empty list when key does not exist.
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
IEnumerable HashKeys(string hashKey, CommandFlags flag = CommandFlags.None);
///
@@ -761,6 +804,7 @@ public interface IRedisDatabase
/// Key of the hash
/// Command execution flag
/// number of fields in the hash, or 0 when key does not exist.
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
long HashLength(string hashKey, CommandFlags flag = CommandFlags.None);
///
@@ -776,6 +820,7 @@ public interface IRedisDatabase
/// true if field is a new field in the hash and value was set.
/// false if field already exists in the hash and no operation was performed.
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool HashSet(string hashKey, string key, T value, bool nx = false, CommandFlags flag = CommandFlags.None);
///
@@ -788,6 +833,7 @@ public interface IRedisDatabase
/// Key of the hash
///
/// Command execution flag
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
void HashSet(string hashKey, Dictionary values, CommandFlags flag = CommandFlags.None);
///
@@ -800,6 +846,7 @@ public interface IRedisDatabase
/// Key of the hash
/// Command execution flag
/// list of values in the hash, or an empty list when key does not exist.
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
IEnumerable HashValues(string hashKey, CommandFlags flag = CommandFlags.None);
///
@@ -815,6 +862,7 @@ public interface IRedisDatabase
/// Number of elements to retrieve from the redis server in the cursor
/// Command execution flag
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
Dictionary HashScan(string hashKey, string pattern, int pageSize = 10, CommandFlags flag = CommandFlags.None);
///
@@ -1020,6 +1068,7 @@ public interface IRedisDatabase
/// The key of the object
/// The new expiry time of the object
/// True if the object is updated, false if the object does not exist
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool UpdateExpiry(string key, DateTimeOffset expiresAt, CommandFlags flag = CommandFlags.None);
///
@@ -1028,6 +1077,7 @@ public interface IRedisDatabase
/// The key of the object
/// Time until the object will expire
/// True if the object is updated, false if the object does not exist
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool UpdateExpiry(string key, TimeSpan expiresIn, CommandFlags flag = CommandFlags.None);
///
@@ -1052,6 +1102,7 @@ public interface IRedisDatabase
/// An array of keys to be updated
/// The new expiry time of the object
/// 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
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
IDictionary UpdateExpiryAll(string[] keys, DateTimeOffset expiresAt, CommandFlags flag = CommandFlags.None);
///
@@ -1060,6 +1111,7 @@ public interface IRedisDatabase
/// An array of keys to be updated
/// Time until the object will expire
/// An IDictionary object that contains the origional key and the result of the operation
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
IDictionary UpdateExpiryAll(string[] keys, TimeSpan expiresIn, CommandFlags flag = CommandFlags.None);
///
@@ -1091,6 +1143,7 @@ public interface IRedisDatabase
///
/// True if the object has been added. Otherwise false
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool SortedSetAdd(string key, T value, double score, CommandFlags flag = CommandFlags.None);
///
@@ -1120,6 +1173,7 @@ public interface IRedisDatabase
///
/// True if the object has been removed. Otherwise false
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
bool SortedSetRemove(string key, T value, CommandFlags flag = CommandFlags.None);
///
@@ -1153,6 +1207,7 @@ public interface IRedisDatabase
///
/// True if the object has been removed. Otherwise false
///
+ [Obsolete("The sync method will be removed with the next version. Please use the Async version.")]
IEnumerable SortedSetRangeByScore(string key, double start = double.NegativeInfinity, double stop = double.PositiveInfinity, Exclude exclude = Exclude.None, Order order = Order.Ascending, long skip = 0L, long take = -1L, CommandFlags flag = CommandFlags.None);
///
diff --git a/src/StackExchange.Redis.Extensions.Core/Configuration/RedisConfiguration.cs b/src/StackExchange.Redis.Extensions.Core/Configuration/RedisConfiguration.cs
index 75a016ce..46c29aac 100644
--- a/src/StackExchange.Redis.Extensions.Core/Configuration/RedisConfiguration.cs
+++ b/src/StackExchange.Redis.Extensions.Core/Configuration/RedisConfiguration.cs
@@ -18,7 +18,7 @@ public class RedisConfiguration
private RedisHost[] hosts;
private ServerEnumerationStrategy serverEnumerationStrategy;
private int poolSize = 10;
- private string[] excludeCommands;
+ private string[] excludeCommands;
///
/// The key separation prefix used for all cache entries
@@ -210,7 +210,6 @@ public ConfigurationOptions ConfigurationOptions
AbortOnConnectFail = AbortOnConnectFail,
};
- // EXCLUDE commands if any requested
if (ExcludeCommands != null)
{
options.CommandMap = CommandMap.Create(
diff --git a/src/StackExchange.Redis.Extensions.Core/ICacheClient.cs b/src/StackExchange.Redis.Extensions.Core/ICacheClient.cs
index b847dade..8c3165f4 100644
--- a/src/StackExchange.Redis.Extensions.Core/ICacheClient.cs
+++ b/src/StackExchange.Redis.Extensions.Core/ICacheClient.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
namespace StackExchange.Redis.Extensions.Core
diff --git a/src/StackExchange.Redis.Extensions.Core/StackExchange.Redis.Extensions.Core.csproj b/src/StackExchange.Redis.Extensions.Core/StackExchange.Redis.Extensions.Core.csproj
index f2e0da8a..609dfa23 100644
--- a/src/StackExchange.Redis.Extensions.Core/StackExchange.Redis.Extensions.Core.csproj
+++ b/src/StackExchange.Redis.Extensions.Core/StackExchange.Redis.Extensions.Core.csproj
@@ -13,13 +13,13 @@ To store complex data It requires one of the following implementations:
- StackExchange.Redis.Extensions.Protobuf
- StackExchange.Redis.Extensions.Utf8Json
- StackExchange.Redis.Extensions.Binary
- 5.1.0
+ 5.1.1
false
true
Ugo Lattanzi
Ugo Lattanzi
- true
+ false
StackExchange.Redis.Extensions.Core
..\..\StackExchange.Redis.Extensions.Core.snk
true
diff --git a/src/StackExchange.Redis.Extensions.Jil/StackExchange.Redis.Extensions.Jil.csproj b/src/StackExchange.Redis.Extensions.Jil/StackExchange.Redis.Extensions.Jil.csproj
index 11da4c28..bbb3a6c7 100644
--- a/src/StackExchange.Redis.Extensions.Jil/StackExchange.Redis.Extensions.Jil.csproj
+++ b/src/StackExchange.Redis.Extensions.Jil/StackExchange.Redis.Extensions.Jil.csproj
@@ -8,7 +8,7 @@
StackExchange.Redis.Extensions is a library that extends StackExchange.Redis allowing you a set of functionality needed by common applications.
This implementation is based on Jil serializer.
- 5.1.0
+ 5.1.1
Ugo Lattanzi
Ugo Lattanzi
diff --git a/src/StackExchange.Redis.Extensions.LegacyConfiguration/StackExchange.Redis.Extensions.LegacyConfiguration.nuspec b/src/StackExchange.Redis.Extensions.LegacyConfiguration/StackExchange.Redis.Extensions.LegacyConfiguration.nuspec
index f7d71c81..3472fcfe 100644
--- a/src/StackExchange.Redis.Extensions.LegacyConfiguration/StackExchange.Redis.Extensions.LegacyConfiguration.nuspec
+++ b/src/StackExchange.Redis.Extensions.LegacyConfiguration/StackExchange.Redis.Extensions.LegacyConfiguration.nuspec
@@ -23,7 +23,7 @@
en-US
Async Redis NoSQL Client Distributed Cache PubSub Messaging
-
+
\ No newline at end of file
diff --git a/src/StackExchange.Redis.Extensions.MsgPack/StackExchange.Redis.Extensions.MsgPack.csproj b/src/StackExchange.Redis.Extensions.MsgPack/StackExchange.Redis.Extensions.MsgPack.csproj
index 20da2b5a..ce1f2a4a 100644
--- a/src/StackExchange.Redis.Extensions.MsgPack/StackExchange.Redis.Extensions.MsgPack.csproj
+++ b/src/StackExchange.Redis.Extensions.MsgPack/StackExchange.Redis.Extensions.MsgPack.csproj
@@ -8,7 +8,7 @@
StackExchange.Redis.Extensions is a library that extends StackExchange.Redis allowing you a set of functionality needed by common applications.
This implementation is based on MsgPack serializer.
- 5.1.0
+ 5.1.1
Ugo Lattanzi
Ugo Lattanzi
diff --git a/src/StackExchange.Redis.Extensions.Newtonsoft/StackExchange.Redis.Extensions.Newtonsoft.csproj b/src/StackExchange.Redis.Extensions.Newtonsoft/StackExchange.Redis.Extensions.Newtonsoft.csproj
index 920bb193..d6876cee 100644
--- a/src/StackExchange.Redis.Extensions.Newtonsoft/StackExchange.Redis.Extensions.Newtonsoft.csproj
+++ b/src/StackExchange.Redis.Extensions.Newtonsoft/StackExchange.Redis.Extensions.Newtonsoft.csproj
@@ -8,7 +8,7 @@
StackExchange.Redis.Extensions is a library that extends StackExchange.Redis allowing you a set of functionality needed by common applications.
This implementation is based on Newtonsoft Json.Net serializer.
- 5.1.0
+ 5.1.1
Ugo Lattanzi
Ugo Lattanzi
diff --git a/src/StackExchange.Redis.Extensions.Protobuf/StackExchange.Redis.Extensions.Protobuf.csproj b/src/StackExchange.Redis.Extensions.Protobuf/StackExchange.Redis.Extensions.Protobuf.csproj
index 76194fec..65b0008b 100644
--- a/src/StackExchange.Redis.Extensions.Protobuf/StackExchange.Redis.Extensions.Protobuf.csproj
+++ b/src/StackExchange.Redis.Extensions.Protobuf/StackExchange.Redis.Extensions.Protobuf.csproj
@@ -8,7 +8,7 @@
StackExchange.Redis.Extensions is a library that extends StackExchange.Redis allowing you a set of functionality needed by common applications.
This implementation is based on Protobuf serializer.
- 5.1.0
+ 5.1.1
Ugo Lattanzi
Ugo Lattanzi
diff --git a/src/StackExchange.Redis.Extensions.Utf8Json/StackExchange.Redis.Extensions.Utf8Json.csproj b/src/StackExchange.Redis.Extensions.Utf8Json/StackExchange.Redis.Extensions.Utf8Json.csproj
index 1199991c..4c39932f 100644
--- a/src/StackExchange.Redis.Extensions.Utf8Json/StackExchange.Redis.Extensions.Utf8Json.csproj
+++ b/src/StackExchange.Redis.Extensions.Utf8Json/StackExchange.Redis.Extensions.Utf8Json.csproj
@@ -8,7 +8,7 @@
StackExchange.Redis.Extensions is a library that extends StackExchange.Redis allowing you a set of functionality needed by common applications.
This implementation is based on UTF8Json serializer.
- 5.1.0
+ 5.1.1
Ugo Lattanzi
Ugo Lattanzi
diff --git a/tests/StackExchange.Redis.Extensions.Tests/CacheClientTestBase.cs b/tests/StackExchange.Redis.Extensions.Tests/CacheClientTestBase.cs
index a4313100..57380e6e 100644
--- a/tests/StackExchange.Redis.Extensions.Tests/CacheClientTestBase.cs
+++ b/tests/StackExchange.Redis.Extensions.Tests/CacheClientTestBase.cs
@@ -34,7 +34,7 @@ protected CacheClientTestBase(ISerializer serializer)
KeyPrefix = "MyPrefix__",
Hosts = new RedisHost[]
{
- new RedisHost(){Host = "redishost", Port = 6379}
+ new RedisHost(){Host = "localhost", Port = 6379}
},
AllowAdmin = true,
ConnectTimeout = 3000,
@@ -48,7 +48,6 @@ protected CacheClientTestBase(ISerializer serializer)
};
Serializer = serializer;
- //redisCacheConnectionPoolManager = new SinglePool(redisConfiguration);
ConnectionPoolManager = new RedisCacheConnectionPoolManager(redisConfiguration);
Sut = new RedisCacheClient(ConnectionPoolManager, Serializer, redisConfiguration);
Db = Sut.GetDbFromConfiguration().Database;
@@ -62,9 +61,9 @@ public void Dispose()
}
[Fact]
- public void Info_Should_Return_Valid_Information()
+ public async Task Info_Should_Return_Valid_Information()
{
- var response = Sut.GetDbFromConfiguration().GetInfo();
+ var response = await Sut.GetDbFromConfiguration().GetInfoAsync();
Assert.NotNull(response);
Assert.True(response.Any());
@@ -72,26 +71,26 @@ public void Info_Should_Return_Valid_Information()
}
[Fact]
- public void Add_Item_To_Redis_Database()
+ public async Task Add_Item_To_Redis_Database()
{
- var added = Sut.GetDbFromConfiguration().Add("my Key", "my value");
+ var added = await Sut.GetDbFromConfiguration().AddAsync("my Key", "my value");
+ var redisValue = await Db.KeyExistsAsync("my Key");
- Assert.True(added);
- Assert.True(Db.KeyExists("my Key"));
+ Assert.True(added);
+ Assert.True(redisValue);
}
[Fact]
- public void Add_Complex_Item_To_Redis_Database()
+ public async Task Add_Complex_Item_To_Redis_Database()
{
var testobject = new TestClass();
- var added = Sut.GetDbFromConfiguration().Add("my Key", testobject);
-
- var result = Db.StringGet("my Key");
+ var added = await Sut.GetDbFromConfiguration().AddAsync("my Key", testobject);
+ var redisValue = await Db.StringGetAsync("my Key");
Assert.True(added);
- var obj = Serializer.Deserialize>(result);
+ var obj = Serializer.Deserialize>(redisValue);
Assert.True(Db.KeyExists("my Key"));
Assert.NotNull(obj);
@@ -100,7 +99,7 @@ public void Add_Complex_Item_To_Redis_Database()
}
[Fact]
- public void Add_Multiple_Object_With_A_Single_Roundtrip_To_Redis_Must_Store_Data_Correctly_Into_Database()
+ public async Task Add_Multiple_Object_With_A_Single_Roundtrip_To_Redis_Must_Store_Data_Correctly_Into_Database()
{
var values = new List>
{
@@ -109,29 +108,34 @@ public void Add_Multiple_Object_With_A_Single_Roundtrip_To_Redis_Must_Store_Data
new Tuple("key3", "value3")
};
- var added = Sut.GetDbFromConfiguration().AddAll(values);
+ var added = await Sut.GetDbFromConfiguration().AddAllAsync(values);
Assert.True(added);
- Assert.True(Db.KeyExists("key1"));
- Assert.True(Db.KeyExists("key2"));
- Assert.True(Db.KeyExists("key3"));
+ Assert.True(await Db.KeyExistsAsync("key1"));
+ Assert.True(await Db.KeyExistsAsync("key2"));
+ Assert.True(await Db.KeyExistsAsync("key3"));
- Assert.Equal("value1", Serializer.Deserialize(Db.StringGet("key1")));
- Assert.Equal("value2", Serializer.Deserialize(Db.StringGet("key2")));
- Assert.Equal("value3", Serializer.Deserialize(Db.StringGet("key3")));
+ Assert.Equal("value1", Serializer.Deserialize(await Db.StringGetAsync("key1")));
+ Assert.Equal("value2", Serializer.Deserialize(await Db.StringGetAsync("key2")));
+ Assert.Equal("value3", Serializer.Deserialize(await Db.StringGetAsync("key3")));
}
[Fact]
- public void Get_All_Should_Return_All_Database_Keys()
+ public async Task Get_All_Should_Return_All_Database_Keys()
{
var values = Range(0, 5)
.Select(i => new TestClass($"Key{i}", Guid.NewGuid().ToString()))
.ToArray();
- values.ForEach(x => Db.StringSet(x.Key, Serializer.Serialize(x.Value)));
+ foreach(var x in values)
+ {
+ await Db.StringSetAsync(x.Key, Serializer.Serialize(x.Value));
+ }
+
+ var keys = new[] { values[0].Key, values[1].Key, values[2].Key, "notexistingkey" };
- var result = Sut.GetDbFromConfiguration().GetAll(new[] { values[0].Key, values[1].Key, values[2].Key, "notexistingkey" });
+ var result = await Sut.GetDbFromConfiguration().GetAllAsync(keys);
Assert.True(result.Count() == 4);
Assert.Equal(result[values[0].Key], values[0].Value);
@@ -141,15 +145,15 @@ public void Get_All_Should_Return_All_Database_Keys()
}
[Fact]
- public void Get_With_Complex_Item_Should_Return_Correct_Value()
+ public async Task Get_With_Complex_Item_Should_Return_Correct_Value()
{
var value = Range(0, 1)
.Select(i => new ComplexClassForTest($"Key{i}", Guid.NewGuid()))
.First();
- Db.StringSet(value.Item1, Serializer.Serialize(value));
+ await Db.StringSetAsync(value.Item1, Serializer.Serialize(value));
- var cachedObject = Sut.GetDbFromConfiguration().Get>(value.Item1);
+ var cachedObject = await Sut.GetDbFromConfiguration().GetAsync>(value.Item1);
Assert.NotNull(cachedObject);
Assert.Equal(value.Item1, cachedObject.Item1);
@@ -157,14 +161,18 @@ public void Get_With_Complex_Item_Should_Return_Correct_Value()
}
[Fact]
- public void Remove_All_Should_Remove_All_Specified_Keys()
+ public async Task Remove_All_Should_Remove_All_Specified_Keys()
{
var values = Range(1, 5)
.Select(i => new TestClass($"Key{i}", Guid.NewGuid().ToString()))
.ToArray();
- values.ForEach(x => Db.StringSet(x.Key, x.Value));
- Sut.GetDbFromConfiguration().RemoveAll(values.Select(x => x.Key));
+ foreach(var x in values)
+ {
+ await Db.StringSetAsync(x.Key, x.Value);
+ }
+
+ await Sut.GetDbFromConfiguration().RemoveAllAsync(values.Select(x => x.Key));
foreach (var value in values)
{
@@ -173,41 +181,49 @@ public void Remove_All_Should_Remove_All_Specified_Keys()
}
[Fact]
- public void Search_With_Valid_Start_With_Pattern_Should_Return_Correct_Keys()
+ public async Task Search_With_Valid_Start_With_Pattern_Should_Return_Correct_Keys()
{
var values = Range(1, 20)
.Select(i => new TestClass($"Key{i}", Guid.NewGuid().ToString()))
.ToArray();
- values.ForEach(x => Db.StringSet(x.Key, x.Value));
+ foreach (var x in values)
+ {
+ await Db.StringSetAsync(x.Key, x.Value);
+ }
- var key = Sut.GetDbFromConfiguration().SearchKeys("Key1*").ToList();
+ var key = (await Sut.GetDbFromConfiguration().SearchKeysAsync("Key1*")).ToList();
Assert.True(key.Count == 11);
}
[Fact]
- public void SearchKeys_With_Key_Prefix_Should_Return_All_Database_Keys()
+ public async Task SearchKeys_With_Key_Prefix_Should_Return_All_Database_Keys()
{
- Sut.GetDbFromConfiguration().Add("mykey1", "Foo");
- Sut.GetDbFromConfiguration().Add("mykey2", "Bar");
- Sut.GetDbFromConfiguration().Add("key3", "Bar");
+ var tsk1 = Sut.GetDbFromConfiguration().AddAsync("mykey1", "Foo");
+ var tsk2 = Sut.GetDbFromConfiguration().AddAsync("mykey2", "Bar");
+ var tsk3 = Sut.GetDbFromConfiguration().AddAsync("key3", "Bar");
- var keys = Sut.GetDbFromConfiguration().SearchKeys("*mykey*");
+ await Task.WhenAll(tsk1, tsk2, tsk3);
+
+ var keys = await Sut.GetDbFromConfiguration().SearchKeysAsync("*mykey*");
Assert.True(keys.Count() == 2);
}
[Fact]
- public void SearchKeys_With_Key_Prefix_Should_Return_Keys_Without_Prefix()
+ public async Task SearchKeys_With_Key_Prefix_Should_Return_Keys_Without_Prefix()
{
var values = Range(0, 10)
.Select(i => new TestClass($"mykey{i}", Guid.NewGuid().ToString()))
.ToArray();
- values.ForEach(x => Sut.GetDbFromConfiguration().Add(x.Key, x.Value));
+ foreach (var x in values)
+ {
+ await Db.StringSetAsync(x.Key, x.Value);
+ }
- var result = Sut.GetDbFromConfiguration().SearchKeys("*mykey*").OrderBy(k => k).ToList();
+ var result = (await Sut.GetDbFromConfiguration().SearchKeysAsync("*mykey*")).OrderBy(k => k).ToList();
Assert.True(result.Count == 10);
@@ -218,38 +234,46 @@ public void SearchKeys_With_Key_Prefix_Should_Return_Keys_Without_Prefix()
}
[Fact]
- public void Exist_With_Valid_Object_Should_Return_The_Correct_Instance()
+ public async Task Exist_With_Valid_Object_Should_Return_The_Correct_Instance()
{
var values = Range(0, 2)
.Select(_ => new TestClass(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()))
.ToArray();
- values.ForEach(x => Db.StringSet(x.Key, x.Value));
- Assert.True(Sut.GetDbFromConfiguration().Exists(values[0].Key));
+ foreach (var x in values)
+ {
+ await Db.StringSetAsync(x.Key, x.Value);
+ }
+
+ Assert.True(await Sut.GetDbFromConfiguration().ExistsAsync(values[0].Key));
}
[Fact]
- public void Exist_With_Not_Valid_Object_Should_Return_The_Correct_Instance()
+ public async Task Exist_With_Not_Valid_Object_Should_Return_The_Correct_Instance()
{
var values = Range(0, 2)
.Select(_ => new TestClass(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()));
- values.ForEach(x => Db.StringSet(x.Key, x.Value));
- Assert.False(Sut.GetDbFromConfiguration().Exists("this key doesn not exist into redi"));
+ foreach (var x in values)
+ {
+ await Db.StringSetAsync(x.Key, x.Value);
+ }
+
+ Assert.False(await Sut.GetDbFromConfiguration().ExistsAsync("this key doesn not exist into redi"));
}
[Fact]
- public void SetAdd_With_An_Existing_Key_Should_Return_Valid_Data()
+ public async Task SetAdd_With_An_Existing_Key_Should_Return_Valid_Data()
{
var values = Range(0, 5)
.Select(_ => new TestClass(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()))
.ToArray();
- values.ForEach(x =>
- {
- Db.StringSet(x.Key, Serializer.Serialize(x.Value));
- Sut.GetDbFromConfiguration().SetAdd("MySet", x.Key);
- });
+ foreach(var x in values)
+ {
+ await Db.StringSetAsync(x.Key, Serializer.Serialize(x.Value));
+ await Sut.GetDbFromConfiguration().SetAddAsync("MySet", x.Key);
+ };
var keys = Db.SetMembers("MySet");
@@ -257,16 +281,16 @@ public void SetAdd_With_An_Existing_Key_Should_Return_Valid_Data()
}
[Fact]
- public void SetMembers_With_Valid_Data_Should_Return_Correct_Keys()
+ public async Task SetMembers_With_Valid_Data_Should_Return_Correct_Keys()
{
var values = Range(0, 5).Select(_ => new TestClass(Guid.NewGuid().ToString(), Guid.NewGuid().ToString())).ToArray();
- values.ForEach(x =>
- {
- Db.SetAdd("MySet", Serializer.Serialize(x));
- });
+ foreach (var x in values)
+ {
+ await Db.SetAddAsync("MySet", Serializer.Serialize(x));
+ };
- var keys = (Sut.GetDbFromConfiguration().SetMembers>("MySet")).ToArray();
+ var keys = (await Sut.GetDbFromConfiguration().SetMembersAsync>("MySet")).ToArray();
Assert.Equal(keys.Length, values.Length);
@@ -277,30 +301,30 @@ public void SetMembers_With_Valid_Data_Should_Return_Correct_Keys()
}
[Fact]
- public void SetMember_With_Valid_Data_Should_Return_Correct_Keys()
+ public async Task SetMember_With_Valid_Data_Should_Return_Correct_Keys()
{
var values = Range(0, 5).Select(_ => new TestClass(Guid.NewGuid().ToString(), Guid.NewGuid().ToString())).ToArray();
- values.ForEach(x =>
- {
- Db.StringSet(x.Key, Serializer.Serialize(x.Value));
- Db.SetAdd("MySet", x.Key);
- });
+ foreach (var x in values)
+ {
+ await Db.StringSetAsync(x.Key, Serializer.Serialize(x.Value));
+ await Db.SetAddAsync("MySet", x.Key);
+ };
- var keys = Sut.GetDbFromConfiguration().SetMember("MySet");
+ var keys = await Sut.GetDbFromConfiguration().SetMemberAsync("MySet");
Assert.Equal(keys.Length, values.Length);
}
[Fact]
- public async void SetMembersAsync_With_Valid_Data_Should_Return_Correct_Keys()
+ public async Task SetMembers_With_Complex_Object_And_Valid_Data_Should_Return_Correct_Keys()
{
var values = Range(0, 5).Select(_ => new TestClass(Guid.NewGuid().ToString(), Guid.NewGuid().ToString())).ToArray();
- values.ForEach(x =>
- {
- Db.SetAdd("MySet", Serializer.Serialize(x));
- });
+ foreach (var x in values)
+ {
+ await Db.SetAddAsync("MySet", Serializer.Serialize(x));
+ };
var keys = (await Sut.GetDbFromConfiguration().SetMembersAsync>("MySet")).ToArray();
@@ -308,14 +332,14 @@ public async void SetMembersAsync_With_Valid_Data_Should_Return_Correct_Keys()
}
[Fact]
- public void Massive_Add_Should_Not_Throw_Exception_And_Work_Correctly()
+ public async Task Massive_Add_Should_Not_Throw_Exception_And_Work_Correctly()
{
const int size = 3000;
var values = Range(0, size).Select(_ => new TestClass(Guid.NewGuid().ToString(), Guid.NewGuid().ToString())).ToArray();
var tupleValues = values.Select(x => new Tuple>(x.Key, x)).ToList();
- var result = Sut.GetDbFromConfiguration().AddAll(tupleValues);
- var cached = Sut.GetDbFromConfiguration().GetAll>(values.Select(x => x.Key));
+ var result = await Sut.GetDbFromConfiguration().AddAllAsync(tupleValues);
+ var cached = await Sut.GetDbFromConfiguration().GetAllAsync>(values.Select(x => x.Key));
Assert.True(result);
Assert.NotNull(cached);
@@ -329,11 +353,11 @@ public void Massive_Add_Should_Not_Throw_Exception_And_Work_Correctly()
}
[Fact]
- public void Adding_Value_Type_Should_Return_Correct_Value()
+ public async Task Adding_Value_Type_Should_Return_Correct_Value()
{
var d = 1;
- var added = Sut.GetDbFromConfiguration().Add("my Key", d);
- var dbValue = Sut.GetDbFromConfiguration().Get("my Key");
+ var added = await Sut.GetDbFromConfiguration().AddAsync("my Key", d);
+ var dbValue = await Sut.GetDbFromConfiguration().GetAsync("my Key");
Assert.True(added);
Assert.True(Db.KeyExists("my Key"));
@@ -341,15 +365,16 @@ public void Adding_Value_Type_Should_Return_Correct_Value()
}
[Fact]
- public void Adding_Collection_To_Redis_Should_Work_Correctly()
+ public async Task Adding_Collection_To_Redis_Should_Work_Correctly()
{
var items = Range(1, 3).Select(i => new TestClass { Key = $"key{i}", Value = "value{i}" }).ToArray();
- var added = Sut.GetDbFromConfiguration().Add("my Key", items);
- var dbValue = Sut.GetDbFromConfiguration().Get[]>("my Key");
+ var added = await Sut.GetDbFromConfiguration().AddAsync("my Key", items);
+ var dbValue = await Sut.GetDbFromConfiguration().GetAsync[]>("my Key");
Assert.True(added);
- Assert.True(Db.KeyExists("my Key"));
+ Assert.True(await Db.KeyExistsAsync("my Key"));
Assert.Equal(dbValue.Length, items.Length);
+
for (var i = 0; i < items.Length; i++)
{
Assert.Equal(dbValue[i].Value, items[i].Value);
@@ -358,41 +383,43 @@ public void Adding_Collection_To_Redis_Should_Work_Correctly()
}
[Fact]
- public void Adding_Collection_To_Redis_Should_Expire()
+ public async Task Adding_Collection_To_Redis_Should_Expire()
{
var expiresIn = new TimeSpan(0, 0, 1);
var items = Range(1, 3).Select(i => new Tuple($"key{i}", "value{i}")).ToArray();
- var added = Sut.GetDbFromConfiguration().AddAll(items, expiresIn);
+ var added = await Sut.GetDbFromConfiguration().AddAllAsync(items, expiresIn);
- Thread.Sleep(expiresIn.Add(new TimeSpan(0, 0, 1)));
+ await Task.Delay(expiresIn.Add(new TimeSpan(0, 0, 1)));
var hasExpired = items.All(x => !Db.KeyExists(x.Item1));
Assert.True(added);
Assert.True(hasExpired);
}
- //[Fact(Skip = "AppVeyor, see here http://help.appveyor.com/discussions/problems/3760-vs-runner-hangs-on-run-all")]
[Fact]
- public void Pub_Sub()
+ public async Task Pub_Sub()
{
var message = Range(0, 10).ToArray();
var channel = new RedisChannel(Encoding.UTF8.GetBytes("unit_test"), RedisChannel.PatternMode.Auto);
var subscriberNotified = false;
IEnumerable subscriberValue = null;
- Action> action = value =>
- {
- subscriberNotified = true;
- subscriberValue = value;
- };
+ Func, Task> action = value => {
+ {
+ subscriberNotified = true;
+ subscriberValue = value;
+ }
+
+ return Task.CompletedTask;
+ };
- Sut.GetDbFromConfiguration().Subscribe(channel, action);
+ await Sut.GetDbFromConfiguration().SubscribeAsync(channel, action);
- var result = Sut.GetDbFromConfiguration().Publish(channel, message);
+ var result = await Sut.GetDbFromConfiguration().PublishAsync(channel, message);
while (!subscriberNotified)
{
- Thread.Sleep(100);
+ await Task.Delay(100);
}
Assert.Equal(1, result);
@@ -401,29 +428,29 @@ public void Pub_Sub()
}
[Fact]
- public void SetAddGenericShouldThrowExceptionWhenKeyIsEmpty()
+ public async Task SetAddGenericShouldThrowExceptionWhenKeyIsEmpty()
{
- Assert.Throws(() => Sut.GetDbFromConfiguration().SetAdd(string.Empty, string.Empty));
+ await Assert.ThrowsAsync(() => Sut.GetDbFromConfiguration().SetAddAsync(string.Empty, string.Empty));
}
[Fact]
- public void SetAddGenericShouldThrowExceptionWhenItemIsNull()
+ public async Task SetAddGenericShouldThrowExceptionWhenItemIsNull()
{
- Assert.Throws(() => Sut.GetDbFromConfiguration().SetAdd("MySet", null));
+ await Assert.ThrowsAsync(() => Sut.GetDbFromConfiguration().SetAddAsync("MySet", null));
}
[Fact]
- public void SetAddGeneric_With_An_Existing_Key_Should_Return_Valid_Data()
+ public async Task SetAddGeneric_With_An_Existing_Key_Should_Return_Valid_Data()
{
var values = Range(0, 5).Select(_ => new TestClass(Guid.NewGuid().ToString(), Guid.NewGuid().ToString())).ToList();
- values.ForEach(x =>
- {
- Db.StringSet(x.Key, Serializer.Serialize(x.Value));
- Sut.GetDbFromConfiguration().SetAdd("MySet", x);
- });
+ foreach(var x in values)
+ {
+ await Db.StringSetAsync(x.Key, Serializer.Serialize(x.Value));
+ await Sut.GetDbFromConfiguration().SetAddAsync("MySet", x);
+ }
- var keys = Db.SetMembers("MySet");
+ var keys = await Db.SetMembersAsync("MySet");
Assert.Equal(keys.Length, values.Count);
}
@@ -431,123 +458,46 @@ public void SetAddGeneric_With_An_Existing_Key_Should_Return_Valid_Data()
[Fact]
public async Task SetAddAsyncGenericShouldThrowExceptionWhenKeyIsEmpty()
{
- try
- {
- await Sut.GetDbFromConfiguration().SetAddAsync(string.Empty, string.Empty);
- }
- catch (Exception ex)
- {
- Assert.IsType(ex);
- }
+ await Assert.ThrowsAsync(() => Sut.GetDbFromConfiguration().SetAddAsync(string.Empty, string.Empty) );
}
[Fact]
public async Task SetAddAsyncGenericShouldThrowExceptionWhenItemIsNull()
{
- try
- {
- await Sut.GetDbFromConfiguration().SetAddAsync("MySet", null);
- }
- catch (Exception ex)
- {
- Assert.IsType(ex);
- }
- }
-
- [Fact]
- public async Task SetAddAsyncGeneric_With_An_Existing_Key_Should_Return_Valid_Data()
- {
- var values = Range(0, 5).Select(_ => new TestClass(Guid.NewGuid().ToString(), Guid.NewGuid().ToString())).ToList();
-
- var key = "MySet";
-
- foreach (var value in values)
- {
- Db.StringSet(value.Key, Serializer.Serialize(value.Value));
- var result = await Sut.GetDbFromConfiguration().SetAddAsync(key, value);
- Assert.True(result, $"SetAddAsync {key}:{value} failed");
- }
-
- var keys = Db.SetMembers("MySet");
-
- Assert.Equal(keys.Length, values.Count);
- }
-
- [Fact]
- public void SetAddAllGenericShouldReturnValidData()
- {
- var items = new[] { "val1", "val2", "val3" };
- long result = Sut.GetDbFromConfiguration().SetAddAll("MySet", CommandFlags.None, items);
- Assert.Equal(result, items.Length);
- }
-
- [Fact]
- public void SetAddAllGenericShouldThrowExceptionWhenItemsIsNull()
- {
- try
- {
- long result = Sut.GetDbFromConfiguration().SetAddAll("MySet", CommandFlags.None, (string[])null);
- }
- catch (Exception ex)
- {
- Assert.IsType(ex);
- }
- }
-
- [Fact]
- public void SetAddAllGenericShouldThrowExceptionWhenItemsContainsOneNullItem()
- {
- try
- {
- long result = Sut.GetDbFromConfiguration().SetAddAll("MySet", CommandFlags.None, "value", null, "value2");
- }
- catch (Exception ex)
- {
- Assert.IsType(ex);
- }
- }
+ await Assert.ThrowsAsync(() => Sut.GetDbFromConfiguration().SetAddAsync("MySet", null));
+ }
[Fact]
- public async Task SetAddAllAsyncGenericShouldReturnValidData()
+ public async Task SetAddAllGenericShouldThrowExceptionWhenItemsIsNull()
{
- var items = new[] { "val1", "val2", "val3" };
- long result = await Sut.GetDbFromConfiguration().SetAddAllAsync("MySet", CommandFlags.None, items);
- Assert.Equal(result, items.Length);
+ await Assert.ThrowsAsync(() => Sut.GetDbFromConfiguration().SetAddAllAsync("MySet", CommandFlags.None, (string[])null));
}
[Fact]
- public async Task SetAddAllAsyncGenericShouldThrowExceptionWhenItemsContainsOneNullItem()
+ public async Task SetAddAllGenericShouldThrowExceptionWhenItemsContainsOneNullItem()
{
- try
- {
- var items = new string[] { "value", null, "value2" };
- long result = await Sut.GetDbFromConfiguration().SetAddAllAsync("MySet", CommandFlags.None, items);
- }
- catch (Exception ex)
- {
- Assert.IsType(ex);
- }
+ await Assert.ThrowsAsync(() => Sut.GetDbFromConfiguration().SetAddAllAsync("MySet", CommandFlags.None, "value", null, "value2"));
}
[Fact]
- public void SetRemoveGenericWithAnExistingItemShouldReturnTrue()
+ public async Task SetRemoveGenericWithAnExistingItemShouldReturnTrue()
{
const string key = "MySet", item = "MyItem";
- Sut.GetDbFromConfiguration().SetAdd(key, item);
+ await Sut.GetDbFromConfiguration().SetAddAsync(key, item);
- var result = Sut.GetDbFromConfiguration().SetRemove(key, item);
+ var result = await Sut.GetDbFromConfiguration().SetRemoveAsync(key, item);
Assert.True(result);
}
[Fact]
- public void SetRemoveGenericWithAnUnexistingItemShouldReturnFalse()
+ public async Task SetRemoveGenericWithAnUnexistingItemShouldReturnFalse()
{
const string key = "MySet";
- Sut.GetDbFromConfiguration().SetAdd(key, "ExistingItem");
+ await Sut.GetDbFromConfiguration().SetAddAsync(key, "ExistingItem");
- var result = Sut.GetDbFromConfiguration().SetRemove(key, "UnexistingItem");
+ var result = await Sut.GetDbFromConfiguration().SetRemoveAsync(key, "UnexistingItem");
Assert.False(result);
}
@@ -556,44 +506,25 @@ public async Task SetRemoveAsyncGenericWithAnExistingItemShouldReturnTrue()
{
const string key = "MySet", item = "MyItem";
- Sut.GetDbFromConfiguration().SetAdd(key, item);
+ await Sut.GetDbFromConfiguration().SetAddAsync(key, item);
var result = await Sut.GetDbFromConfiguration().SetRemoveAsync(key, item);
Assert.True(result);
}
[Fact]
- public void SetRemoveAllGenericWithAnExistingItemShouldReturnValidData()
- {
- const string key = "MySet";
- var items = new[] { "MyItem1", "MyItem2" };
-
- Sut.GetDbFromConfiguration().SetAddAll(key, CommandFlags.None, items);
-
- var result = Sut.GetDbFromConfiguration().SetRemoveAll(key, CommandFlags.None, items);
- Assert.Equal(items.Length, result);
- }
-
- [Fact]
- public void SetRemoveAllGenericShouldThrowExceptionWhenItemsContainsOneNullItem()
+ public async Task SetRemoveAllGenericShouldThrowExceptionWhenItemsContainsOneNullItem()
{
- try
- {
- long result = Sut.GetDbFromConfiguration().SetRemoveAll("MySet",CommandFlags.None, "value", null, "value2");
- }
- catch (Exception ex)
- {
- Assert.IsType(ex);
- }
+ await Assert.ThrowsAsync(() => Sut.GetDbFromConfiguration().SetRemoveAllAsync("MySet", CommandFlags.None, "value", null, "value2"));
}
[Fact]
- public async Task SetRemoveAllAsyncGenericWithAnExistingItemShouldReturnValidData()
+ public async Task SetRemoveAllGenericWithAnExistingItemShouldReturnValidData()
{
const string key = "MySet";
var items = new[] { "MyItem1", "MyItem2" };
- Sut.GetDbFromConfiguration().SetAddAll(key, CommandFlags.None, items);
+ await Sut.GetDbFromConfiguration().SetAddAllAsync(key, CommandFlags.None, items);
var result = await Sut.GetDbFromConfiguration().SetRemoveAllAsync(key,CommandFlags.None, items);
Assert.Equal(items.Length, result);
@@ -602,38 +533,34 @@ public async Task SetRemoveAllAsyncGenericWithAnExistingItemShouldReturnValidDat
[Fact]
public async Task SetRemoveAllAsyncGenericShouldThrowExceptionWhenItemsContainsOneNullItem()
{
- try
- {
- long result = await Sut.GetDbFromConfiguration().SetRemoveAllAsync("MySet", CommandFlags.None, "value", null, "value2");
- }
- catch (Exception ex)
- {
- Assert.IsType(ex);
- }
+ await Assert.ThrowsAsync(() => Sut.GetDbFromConfiguration().SetRemoveAllAsync("MySet", CommandFlags.None, "value", null, "value2"));
}
[Fact]
- public void ListAddToLeftGenericShouldThrowExceptionWhenKeyIsEmpty()
+ public async Task ListAddToLeftGenericShouldThrowExceptionWhenKeyIsEmpty()
{
- Assert.Throws(() => Sut.GetDbFromConfiguration().ListAddToLeft(string.Empty, string.Empty));
+ await Assert.ThrowsAsync(() => Sut.GetDbFromConfiguration().ListAddToLeftAsync(string.Empty, string.Empty));
}
[Fact]
- public void ListAddToLeftGenericShouldThrowExceptionWhenItemIsNull()
+ public async Task ListAddToLeftGenericShouldThrowExceptionWhenItemIsNull()
{
- Assert.Throws(() => Sut.GetDbFromConfiguration().ListAddToLeft("MyList", null));
+ await Assert.ThrowsAsync(() => Sut.GetDbFromConfiguration().ListAddToLeftAsync("MyList", null));
}
[Fact]
- public void ListAddToLeftGeneric_With_An_Existing_Key_Should_Return_Valid_Data()
+ public async Task ListAddToLeftGeneric_With_An_Existing_Key_Should_Return_Valid_Data()
{
var values = Range(0, 5).Select(_ => new TestClass(Guid.NewGuid().ToString(), Guid.NewGuid().ToString())).ToList();
const string key = "MyList";
- values.ForEach(x => Sut.GetDbFromConfiguration().ListAddToLeft(key, Serializer.Serialize(x)));
+ foreach(var x in values)
+ {
+ await Sut.GetDbFromConfiguration().ListAddToLeftAsync(key, Serializer.Serialize(x));
+ }
- var keys = Db.ListRange(key);
+ var keys = await Db.ListRangeAsync(key);
Assert.Equal(keys.Length, values.Count);
}
@@ -642,14 +569,14 @@ public void ListAddToLeftGeneric_With_An_Existing_Key_Should_Return_Valid_Data()
public async Task ListAddToLeftAsyncGenericShouldThrowExceptionWhenKeyIsEmpty()
{
await Assert.ThrowsAsync(
- async () => await Sut.GetDbFromConfiguration().ListAddToLeftAsync(string.Empty, string.Empty));
+ () => Sut.GetDbFromConfiguration().ListAddToLeftAsync(string.Empty, string.Empty));
}
[Fact]
public async Task ListAddToLeftAsyncGenericShouldThrowExceptionWhenItemIsNull()
{
await Assert.ThrowsAsync(
- async () => await Sut.GetDbFromConfiguration().ListAddToLeftAsync("MyList", null));
+ () => Sut.GetDbFromConfiguration().ListAddToLeftAsync("MyList", null));
}
[Fact]
@@ -664,43 +591,19 @@ public async Task ListAddToLeftAsyncGeneric_With_An_Existing_Key_Should_Return_V
// TODO: why no assertion on the result?
var result = await Sut.GetDbFromConfiguration().ListAddToLeftAsync(key, Serializer.Serialize(value));
}
- var keys = Db.ListRange(key);
+ var keys = await Db.ListRangeAsync(key);
Assert.Equal(keys.Length, values.Count);
}
[Fact]
- public void ListGetFromRightGenericShouldThrowExceptionWhenKeyIsEmpty()
- {
- Assert.Throws(() => Sut.GetDbFromConfiguration().ListGetFromRight(string.Empty));
- }
-
- [Fact]
- public void ListGetFromRightGeneric_With_An_Existing_Key_Should_Return_Valid_Data()
- {
- var values = Range(0, 1)
- .Select(_ => new TestClass(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()))
- .ToArray();
-
- var key = "MyList";
-
- values.ForEach(x => { Db.ListLeftPush(key, Serializer.Serialize(x)); });
-
- var item = Sut.GetDbFromConfiguration().ListGetFromRight>(key);
-
- Assert.Equal(item.Key, values[0].Key);
- Assert.Equal(item.Value, values[0].Value);
- }
-
- [Fact]
- public async Task ListGetFromRightAsyncGenericShouldThrowExceptionWhenKeyIsEmpty()
+ public async Task ListGetFromRightGenericShouldThrowExceptionWhenKeyIsEmpty()
{
- await Assert.ThrowsAsync(
- async () => await Sut.GetDbFromConfiguration().ListGetFromRightAsync(string.Empty));
+ await Assert.ThrowsAsync(() => Sut.GetDbFromConfiguration().ListGetFromRightAsync(string.Empty));
}
[Fact]
- public async Task ListGetFromRightAsyncGeneric_With_An_Existing_Key_Should_Return_Valid_Data()
+ public async Task ListGetFromRightGeneric_With_An_Existing_Key_Should_Return_Valid_Data()
{
var values = Range(0, 1)
.Select(_ => new TestClass(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()))
@@ -708,16 +611,19 @@ public async Task ListGetFromRightAsyncGeneric_With_An_Existing_Key_Should_Retur
var key = "MyList";
- values.ForEach(x => { Db.ListLeftPush(key, Serializer.Serialize(x)); });
-
- var item = await Sut.GetDbFromConfiguration().ListGetFromRightAsync>(key);
+ foreach(var x in values)
+ {
+ await Db.ListLeftPushAsync(key, Serializer.Serialize(x));
+ }
+
+ var item = await Sut.GetDbFromConfiguration().ListGetFromRightAsync>(key);
Assert.Equal(item.Key, values[0].Key);
Assert.Equal(item.Value, values[0].Value);
}
[Fact]
- public async Task ListGetFromRightAsyncGeneric_With_An_Existing_Key_Should_Return_Null_If_List_Is_Empty()
+ public async Task ListGetFromRightGeneric_With_An_Existing_Key_Should_Return_Null_If_List_Is_Empty()
{
var key = "MyList";
@@ -727,17 +633,17 @@ public async Task ListGetFromRightAsyncGeneric_With_An_Existing_Key_Should_Retur
}
[Fact]
- public void ListGetFromRightAsync_With_An_Existing_Key_Should_Return_Null_If_List_Is_Empty()
+ public async Task ListGetFromRight_With_An_Existing_Key_Should_Return_Null_If_List_Is_Empty()
{
var key = "MyList";
- var item = Sut.GetDbFromConfiguration().ListGetFromRight>(key);
+ var item = await Sut.GetDbFromConfiguration().ListGetFromRightAsync>(key);
Assert.Null(item);
}
[Fact]
- public void Get_Value_With_Expiry_Updates_ExpiryAt()
+ public async Task Get_Value_With_Expiry_Updates_ExpiryAt()
{
var key = "TestKey";
var value = "TestValue";
@@ -745,15 +651,15 @@ public void Get_Value_With_Expiry_Updates_ExpiryAt()
var testTime = DateTime.UtcNow.AddSeconds(20);
var resultTimeSpan = originalTime.Subtract(DateTime.UtcNow);
- Sut.GetDbFromConfiguration().Add(key, value, originalTime);
- Sut.GetDbFromConfiguration().Get(key, testTime);
- var resultValue = Db.StringGetWithExpiry(key);
+ await Sut.GetDbFromConfiguration().AddAsync(key, value, originalTime);
+ await Sut.GetDbFromConfiguration().GetAsync(key, testTime);
+ var resultValue = await Db.StringGetWithExpiryAsync(key);
Assert.True(resultTimeSpan < resultValue.Expiry.Value);
}
[Fact]
- public void Get_Value_With_Expiry_Updates_ExpiryIn()
+ public async Task Get_Value_With_Expiry_Updates_ExpiryIn()
{
var key = "TestKey";
var value = "TestValue";
@@ -761,63 +667,15 @@ public void Get_Value_With_Expiry_Updates_ExpiryIn()
var testTime = new TimeSpan(0, 0, 20);
var resultTimeSpan = originalTime;
- Sut.GetDbFromConfiguration().Add(key, value, originalTime);
- Sut.GetDbFromConfiguration().Get(key, testTime);
- var resultValue = Db.StringGetWithExpiry(key);
-
- Assert.True(resultTimeSpan < resultValue.Expiry.Value);
- }
-
- [Fact]
- public async void Get_Value_With_Expiry_Updates_ExpiryAt_Async()
- {
- var key = "TestKey";
- var value = "TestValue";
- var originalTime = DateTime.UtcNow.AddSeconds(5);
- var testTime = DateTime.UtcNow.AddSeconds(20);
-
- await Sut.GetDbFromConfiguration().AddAsync(key, value, originalTime);
- await Sut.GetDbFromConfiguration().GetAsync(key, testTime);
- var resultValue = Db.StringGetWithExpiry(key);
-
- Assert.True(originalTime.Subtract(DateTime.UtcNow) < resultValue.Expiry.Value);
- }
-
- [Fact]
- public async void Get_Value_With_Expiry_Updates_ExpiryIn_Async()
- {
- var key = "TestKey";
- var value = "TestValue";
- var originalTime = DateTime.UtcNow.AddSeconds(5).Subtract(DateTime.UtcNow);
- var testTime = DateTime.UtcNow.AddSeconds(20).Subtract(DateTime.UtcNow);
-
await Sut.GetDbFromConfiguration().AddAsync(key, value, originalTime);
await Sut.GetDbFromConfiguration().GetAsync(key, testTime);
- var resultValue = Db.StringGetWithExpiry(key);
-
- Assert.True(originalTime < resultValue.Expiry.Value);
- }
-
- [Fact]
- public void Get_All_Value_With_Expiry_Updates_Expiry()
- {
- var key = "TestKey";
- var value = new TestClass { Key = key, Value = "Hello World!" };
- var originalTime = DateTime.UtcNow.AddSeconds(5).Subtract(DateTime.UtcNow);
- var testTime = DateTime.UtcNow.AddSeconds(20).Subtract(DateTime.UtcNow);
+ var resultValue = await Db.StringGetWithExpiryAsync(key);
- var values = new List>>() { new Tuple>(key, value) };
- var keys = new List { key };
-
- Sut.GetDbFromConfiguration().AddAll(values, originalTime);
- Sut.GetDbFromConfiguration().GetAll>(keys, testTime);
- var resultValue = Db.StringGetWithExpiry(key);
-
- Assert.True(originalTime < resultValue.Expiry.Value);
+ Assert.True(resultTimeSpan < resultValue.Expiry.Value);
}
[Fact]
- public async void Get_All_Value_With_Expiry_Updates_Expiry_Async()
+ public async Task Get_All_Value_With_Expiry_Updates_Expiry()
{
var key = "TestKey";
var value = new TestClass { Key = key, Value = "Hello World!" };
@@ -829,28 +687,13 @@ public async void Get_All_Value_With_Expiry_Updates_Expiry_Async()
await Sut.GetDbFromConfiguration().AddAllAsync(values, originalTime);
await Sut.GetDbFromConfiguration().GetAllAsync>(keys, testTime);
- var resultValue = Db.StringGetWithExpiry(key);
-
- Assert.True(originalTime < resultValue.Expiry.Value);
- }
-
- [Fact]
- public void Update_Expiry_ExpiresIn()
- {
- var key = "TestKey";
- var value = "Test Value";
- var originalTime = DateTime.UtcNow.AddSeconds(5).Subtract(DateTime.UtcNow);
- var testTime = DateTime.UtcNow.AddSeconds(20).Subtract(DateTime.UtcNow);
+ var resultValue = await Db.StringGetWithExpiryAsync(key);
- Sut.GetDbFromConfiguration().Add(key, value, originalTime);
- Sut.GetDbFromConfiguration().UpdateExpiry(key, testTime);
-
- var resultValue = Db.StringGetWithExpiry(key);
Assert.True(originalTime < resultValue.Expiry.Value);
}
[Fact]
- public async void Update_Expiry_ExpiresIn_Async()
+ public async Task Update_Expiry_ExpiresIn()
{
var key = "TestKey";
var value = "Test Value";
@@ -860,27 +703,12 @@ public async void Update_Expiry_ExpiresIn_Async()
await Sut.GetDbFromConfiguration().AddAsync(key, value, originalTime);
await Sut.GetDbFromConfiguration().UpdateExpiryAsync(key, testTime);
- var resultValue = Db.StringGetWithExpiry(key);
+ var resultValue = await Db.StringGetWithExpiryAsync(key);
Assert.True(originalTime < resultValue.Expiry.Value);
}
[Fact]
- public void Update_Expiry_ExpiresAt()
- {
- var key = "TestKey";
- var value = "Test Value";
- var originalTime = DateTime.UtcNow.AddSeconds(5);
- var testTime = DateTime.UtcNow.AddSeconds(20);
-
- Sut.GetDbFromConfiguration().Add(key, value, originalTime);
- Sut.GetDbFromConfiguration().UpdateExpiry(key, testTime);
-
- var resultValue = Db.StringGetWithExpiry(key);
- Assert.True(originalTime.Subtract(DateTime.UtcNow) < resultValue.Expiry.Value);
- }
-
- [Fact]
- public async void Update_Expiry_ExpiresAt_Async()
+ public async Task Update_Expiry_ExpiresAt_Async()
{
var key = "TestKey";
var value = "Test Value";
@@ -890,14 +718,14 @@ public async void Update_Expiry_ExpiresAt_Async()
await Sut.GetDbFromConfiguration().AddAsync(key, value, originalTime);
await Sut.GetDbFromConfiguration().UpdateExpiryAsync(key, testTime);
- var resultValue = Db.StringGetWithExpiry(key);
+ var resultValue = await Db.StringGetWithExpiryAsync(key);
Assert.True(originalTime.Subtract(DateTime.UtcNow) < resultValue.Expiry.Value);
}
#region Hash tests
[Fact]
- public void HashSetSingleValueNX_ValueDoesntExists_ShouldInsertAndRetrieveValue()
+ public async Task HashSetSingleValueNX_ValueDoesntExists_ShouldInsertAndRetrieveValue()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
@@ -905,36 +733,40 @@ public void HashSetSingleValueNX_ValueDoesntExists_ShouldInsertAndRetrieveValue(
var entryValue = new TestClass("test", DateTime.UtcNow);
// act
- var res = Sut.GetDbFromConfiguration().HashSet(hashKey, entryKey, entryValue, nx: true);
+ var res = await Sut.GetDbFromConfiguration().HashSetAsync(hashKey, entryKey, entryValue, nx: true);
// assert
Assert.True(res);
- var data = Serializer.Deserialize>(Sut.GetDbFromConfiguration().Database.HashGet(hashKey, entryKey));
+
+ var redisValue = await Db.HashGetAsync(hashKey, entryKey);
+ var data = Serializer.Deserialize>(redisValue);
+
Assert.Equal(entryValue, data);
}
[Fact]
- public void HashSetSingleValueNX_ValueExists_ShouldNotInsertOriginalValueNotChanged()
+ public async Task HashSetSingleValueNX_ValueExists_ShouldNotInsertOriginalValueNotChanged()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
var entryKey = Guid.NewGuid().ToString();
var entryValue = new TestClass("test1", DateTime.UtcNow);
var initialValue = new TestClass("test2", DateTime.UtcNow);
- var initRes = Sut.GetDbFromConfiguration().HashSet(hashKey, entryKey, initialValue);
+ var initRes = await Sut.GetDbFromConfiguration().HashSetAsync(hashKey, entryKey, initialValue);
// act
- var res = Sut.GetDbFromConfiguration().HashSet(hashKey, entryKey, entryValue, nx: true);
+ var res = await Sut.GetDbFromConfiguration().HashSetAsync(hashKey, entryKey, entryValue, nx: true);
// assert
Assert.True(initRes);
Assert.False(res);
- var data = Serializer.Deserialize>(Sut.GetDbFromConfiguration().Database.HashGet(hashKey, entryKey));
+ var redisvalue = await Db.HashGetAsync(hashKey, entryKey);
+ var data = Serializer.Deserialize>(redisvalue);
Assert.Equal(initialValue, data);
}
[Fact]
- public void HashSetSingleValue_ValueExists_ShouldUpdateValue()
+ public async Task HashSetSingleValue_ValueExists_ShouldUpdateValue()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
@@ -944,7 +776,7 @@ public void HashSetSingleValue_ValueExists_ShouldUpdateValue()
var initRes = Sut.GetDbFromConfiguration().Database.HashSet(hashKey, entryKey, Serializer.Serialize(initialValue));
// act
- var res = Sut.GetDbFromConfiguration().HashSet(hashKey, entryKey, entryValue, nx: false);
+ var res = await Sut.GetDbFromConfiguration().HashSetAsync(hashKey, entryKey, entryValue, nx: false);
// assert
Assert.True(initRes, "Initial value was not set");
@@ -954,7 +786,7 @@ public void HashSetSingleValue_ValueExists_ShouldUpdateValue()
}
[Fact]
- public void HashSetMultipleValues_HashGetMultipleValues_ShouldInsert()
+ public async Task HashSetMultipleValues_HashGetMultipleValues_ShouldInsert()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
@@ -962,14 +794,17 @@ public void HashSetMultipleValues_HashGetMultipleValues_ShouldInsert()
var map = values.ToDictionary(val => Guid.NewGuid().ToString());
// act
- Sut.GetDbFromConfiguration().HashSet(hashKey, map);
- Thread.Sleep(500);
+ await Sut.GetDbFromConfiguration().HashSetAsync(hashKey, map);
+ await Task.Delay(500);
+
// assert
- var data = Sut.GetDbFromConfiguration().Database
+ var data = Db
.HashGet(hashKey, map.Keys.Select(x => (RedisValue)x).ToArray()).ToList()
.Select(x => Serializer.Deserialize>(x))
.ToList();
+
Assert.Equal(map.Count, data.Count());
+
foreach (var val in data)
{
Assert.True(map.ContainsValue(val), $"result map doesn't contain value: {val}");
@@ -977,156 +812,158 @@ public void HashSetMultipleValues_HashGetMultipleValues_ShouldInsert()
}
[Fact]
- public void HashDelete_KeyExists_ShouldDelete()
+ public async Task HashDelete_KeyExists_ShouldDelete()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
var entryKey = Guid.NewGuid().ToString();
var entryValue = new TestClass(Guid.NewGuid().ToString(), DateTime.UtcNow);
- Assert.True(Sut.GetDbFromConfiguration().Database.HashSet(hashKey, entryKey, Sut.GetDbFromConfiguration().Serializer.Serialize(entryValue)), "Failed setting test value into redis");
+
+ Assert.True(Db.HashSet(hashKey, entryKey, Sut.GetDbFromConfiguration().Serializer.Serialize(entryValue)), "Failed setting test value into redis");
// act
- var result = Sut.GetDbFromConfiguration().HashDelete(hashKey, entryKey);
+ var result = await Sut.GetDbFromConfiguration().HashDeleteAsync(hashKey, entryKey);
// assert
Assert.True(result);
- Assert.True(Sut.GetDbFromConfiguration().Database.HashGet(hashKey, entryKey).IsNull);
+ Assert.True((await Db.HashGetAsync(hashKey, entryKey)).IsNull);
}
[Fact]
- public void HashDelete_KeyDoesntExist_ShouldReturnFalse()
+ public async Task HashDelete_KeyDoesntExist_ShouldReturnFalse()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
var entryKey = Guid.NewGuid().ToString();
// act
- var result = Sut.GetDbFromConfiguration().HashDelete(hashKey, entryKey);
+ var result = await Sut.GetDbFromConfiguration().HashDeleteAsync(hashKey, entryKey);
// assert
Assert.False(result);
- Assert.True(Sut.GetDbFromConfiguration().Database.HashGet(hashKey, entryKey).IsNull);
+ Assert.True((await Db.HashGetAsync(hashKey, entryKey)).IsNull);
}
[Fact]
- public void HashDeleteMultiple_AllKeysExist_ShouldDeleteAll()
+ public async Task HashDeleteMultiple_AllKeysExist_ShouldDeleteAll()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
var values =
- Enumerable.Range(0, 1000)
+ Range(0, 1000)
.Select(x => new TestClass(Guid.NewGuid().ToString(), x))
.ToDictionary(x => x.Key);
- Sut.GetDbFromConfiguration().Database.HashSet(hashKey,
- values.Select(x => new HashEntry(x.Key, Sut.GetDbFromConfiguration().Serializer.Serialize(x.Value))).ToArray());
+ await Db.HashSetAsync(hashKey, values.Select(x => new HashEntry(x.Key, Sut.GetDbFromConfiguration().Serializer.Serialize(x.Value))).ToArray());
// act
-
- var result = Sut.GetDbFromConfiguration().HashDelete(hashKey, values.Keys);
+ var result = await Sut.GetDbFromConfiguration().HashDeleteAsync(hashKey, values.Keys);
// assert
Assert.Equal(values.Count, result);
- var dbValues = Sut.GetDbFromConfiguration().Database.HashGet(hashKey, values.Select(x => (RedisValue)x.Key).ToArray());
+ var dbValues = await Db.HashGetAsync(hashKey, values.Select(x => (RedisValue)x.Key).ToArray());
Assert.NotNull(dbValues);
Assert.DoesNotContain(dbValues, x => !x.IsNull);
- Assert.Equal(0, Sut.GetDbFromConfiguration().Database.HashLength(hashKey));
+ Assert.Equal(0, await Db.HashLengthAsync(hashKey));
}
[Fact]
- public void HashDeleteMultiple_NotAllKeysExist_ShouldDeleteAllOnlyRequested()
+ public async Task HashDeleteMultiple_NotAllKeysExist_ShouldDeleteAllOnlyRequested()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
+
var valuesDelete =
- Enumerable.Range(0, 1000)
+ Range(0, 1000)
.Select(x => new TestClass(Guid.NewGuid().ToString(), x))
.ToDictionary(x => x.Key);
+
var valuesKeep =
- Enumerable.Range(0, 1000)
+ Range(0, 1000)
.Select(x => new TestClass(Guid.NewGuid().ToString(), x))
.ToDictionary(x => x.Key);
- Sut.GetDbFromConfiguration().Database.HashSet(hashKey,
+ await Db.HashSetAsync(hashKey,
valuesDelete.Select(x => new HashEntry(x.Key, Sut.GetDbFromConfiguration().Serializer.Serialize(x.Value))).ToArray());
- Sut.GetDbFromConfiguration().Database.HashSet(hashKey,
+ await Db.HashSetAsync(hashKey,
valuesKeep.Select(x => new HashEntry(x.Key, Sut.GetDbFromConfiguration().Serializer.Serialize(x.Value))).ToArray());
// act
-
- var result = Sut.GetDbFromConfiguration().HashDelete(hashKey, valuesDelete.Keys);
+ var result = await Sut.GetDbFromConfiguration().HashDeleteAsync(hashKey, valuesDelete.Keys);
// assert
Assert.Equal(valuesDelete.Count, result);
- var dbDeletedValues = Sut.GetDbFromConfiguration().Database.HashGet(hashKey, valuesDelete.Select(x => (RedisValue)x.Key).ToArray());
+ var dbDeletedValues = await Db.HashGetAsync(hashKey, valuesDelete.Select(x => (RedisValue)x.Key).ToArray());
Assert.NotNull(dbDeletedValues);
Assert.DoesNotContain(dbDeletedValues, x => !x.IsNull);
- var dbValues = Sut.GetDbFromConfiguration().Database.HashGet(hashKey, valuesKeep.Select(x => (RedisValue)x.Key).ToArray());
+ var dbValues = await Db.HashGetAsync(hashKey, valuesKeep.Select(x => (RedisValue)x.Key).ToArray());
Assert.NotNull(dbValues);
Assert.DoesNotContain(dbValues, x => x.IsNull);
- Assert.Equal(1000, Sut.GetDbFromConfiguration().Database.HashLength(hashKey));
+ Assert.Equal(1000, await Db.HashLengthAsync(hashKey));
Assert.Equal(1000, dbValues.Length);
Assert.All(dbValues, x => Assert.True(valuesKeep.ContainsKey(Sut.GetDbFromConfiguration().Serializer.Deserialize>(x).Key)));
}
[Fact]
- public void HashExists_KeyExists_ReturnTrue()
+ public async Task HashExists_KeyExists_ReturnTrue()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
var entryKey = Guid.NewGuid().ToString();
var entryValue = new TestClass(Guid.NewGuid().ToString(), DateTime.UtcNow);
- Assert.True(Sut.GetDbFromConfiguration().Database.HashSet(hashKey, entryKey, Sut.GetDbFromConfiguration().Serializer.Serialize(entryValue)), "Failed setting test value into redis");
+ Assert.True(await Db.HashSetAsync(hashKey, entryKey, Sut.GetDbFromConfiguration().Serializer.Serialize(entryValue)), "Failed setting test value into redis");
// act
- var result = Sut.GetDbFromConfiguration().HashExists(hashKey, entryKey);
+ var result = await Sut.GetDbFromConfiguration().HashExistsAsync(hashKey, entryKey);
// assert
Assert.True(result, "Entry doesn't exist in hash, but it should");
}
[Fact]
- public void HashExists_KeyDoesntExists_ReturnFalse()
+ public async Task HashExists_KeyDoesntExists_ReturnFalse()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
var entryKey = Guid.NewGuid().ToString();
// act
- var result = Sut.GetDbFromConfiguration().HashExists(hashKey, entryKey);
+ var result = await Sut.GetDbFromConfiguration().HashExistsAsync(hashKey, entryKey);
// assert
Assert.False(result, "Entry doesn't exist in hash, but call returned true");
}
[Fact]
- public void HashKeys_HashEmpty_ReturnEmptyCollection()
+ public async Task HashKeys_HashEmpty_ReturnEmptyCollection()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
// act
- var result = Sut.GetDbFromConfiguration().HashKeys(hashKey);
+ var result = await Sut.GetDbFromConfiguration().HashKeysAsync(hashKey);
// assert
Assert.NotNull(result);
Assert.Empty(result);
}
[Fact]
- public void HashKeys_HashNotEmpty_ReturnKeysCollection()
+ public async Task HashKeys_HashNotEmpty_ReturnKeysCollection()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
var values =
- Enumerable.Range(0, 1000)
+ Range(0, 1000)
.Select(x => new TestClass(Guid.NewGuid().ToString(), x))
.ToDictionary(x => x.Key);
- Sut.GetDbFromConfiguration().Database.HashSet(hashKey,
- values.Select(x => new HashEntry(x.Key, Sut.GetDbFromConfiguration().Serializer.Serialize(x.Value))).ToArray());
+ await Db.HashSetAsync(hashKey, values.Select(x => new HashEntry(x.Key, Sut.GetDbFromConfiguration().Serializer.Serialize(x.Value))).ToArray());
+
// act
- var result = Sut.GetDbFromConfiguration().HashKeys(hashKey);
+ var result = await Sut.GetDbFromConfiguration().HashKeysAsync(hashKey);
+
// assert
Assert.NotNull(result);
var collection = result as IList ?? result.ToList();
Assert.NotEmpty(collection);
Assert.Equal(values.Count, collection.Count());
+
foreach (var key in collection)
{
Assert.True(values.ContainsKey(key));
@@ -1134,36 +971,38 @@ public void HashKeys_HashNotEmpty_ReturnKeysCollection()
}
[Fact]
- public void HashValues_HashEmpty_ReturnEmptyCollection()
+ public async Task HashValues_HashEmpty_ReturnEmptyCollection()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
// act
- var result = Sut.GetDbFromConfiguration().HashValues(hashKey);
+ var result = await Sut.GetDbFromConfiguration().HashValuesAsync(hashKey);
// assert
Assert.NotNull(result);
Assert.Empty(result);
}
[Fact]
- public void HashValues_HashNotEmpty_ReturnAllValues()
+ public async Task HashValues_HashNotEmpty_ReturnAllValues()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
var values =
- Enumerable.Range(0, 1000)
+ Range(0, 1000)
.Select(x => new TestClass(Guid.NewGuid().ToString(), DateTime.UtcNow))
.ToDictionary(x => x.Key);
- Sut.GetDbFromConfiguration().Database.HashSet(hashKey,
- values.Select(x => new HashEntry(x.Key, Sut.GetDbFromConfiguration().Serializer.Serialize(x.Value))).ToArray());
+ await Db.HashSetAsync(hashKey, values.Select(x => new HashEntry(x.Key, Sut.GetDbFromConfiguration().Serializer.Serialize(x.Value))).ToArray());
+
// act
- var result = Sut.GetDbFromConfiguration().HashValues>(hashKey);
+ var result = await Sut.GetDbFromConfiguration().HashValuesAsync>(hashKey);
+
// assert
Assert.NotNull(result);
var collection = result as IList> ?? result.ToList();
Assert.NotEmpty(collection);
Assert.Equal(values.Count, collection.Count());
+
foreach (var key in collection)
{
Assert.Contains(key, values.Values);
@@ -1171,139 +1010,147 @@ public void HashValues_HashNotEmpty_ReturnAllValues()
}
[Fact]
- public void HashLength_HashEmpty_ReturnZero()
+ public async Task HashLength_HashEmpty_ReturnZero()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
// act
- var result = Sut.GetDbFromConfiguration().HashLength(hashKey);
+ var result = await Sut.GetDbFromConfiguration().HashLengthAsync(hashKey);
// assert
Assert.Equal(0, result);
}
[Fact]
- public void HashLength_HashNotEmpty_ReturnCorrectCount()
+ public async Task HashLength_HashNotEmpty_ReturnCorrectCount()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
var values =
- Enumerable.Range(0, 1000)
+ Range(0, 1000)
.Select(x => new TestClass(Guid.NewGuid().ToString(), x))
.ToDictionary(x => x.Key);
- Sut.GetDbFromConfiguration().Database.HashSet(hashKey,
- values.Select(x => new HashEntry(x.Key, Sut.GetDbFromConfiguration().Serializer.Serialize(x.Value))).ToArray());
+ await Db.HashSetAsync(hashKey, values.Select(x => new HashEntry(x.Key, Sut.GetDbFromConfiguration().Serializer.Serialize(x.Value))).ToArray());
+
// act
- var result = Sut.GetDbFromConfiguration().HashLength(hashKey);
+ var result = await Sut.GetDbFromConfiguration().HashLengthAsync(hashKey);
// assert
Assert.Equal(1000, result);
}
[Fact]
- public void HashIncerementByLong_ValueDoesntExist_EntryCreatedWithValue()
+ public async Task HashIncerementByLong_ValueDoesntExist_EntryCreatedWithValue()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
var entryKey = Guid.NewGuid().ToString();
var incBy = 1;
+
// act
- Assert.False(Sut.GetDbFromConfiguration().Database.HashExists(hashKey, entryKey));
- var result = Sut.GetDbFromConfiguration().HashIncerementBy(hashKey, entryKey, incBy);
- // assert
+ Assert.False(Db.HashExists(hashKey, entryKey));
+ var result = await Sut.GetDbFromConfiguration().HashIncerementByAsync(hashKey, entryKey, incBy);
+
+ // assert
Assert.Equal(incBy, result);
- Assert.True(Sut.GetDbFromConfiguration().HashExists(hashKey, entryKey));
- Assert.Equal(incBy, Sut.GetDbFromConfiguration().Database.HashGet(hashKey, entryKey));
+ Assert.True(await Sut.GetDbFromConfiguration().HashExistsAsync(hashKey, entryKey));
+ Assert.Equal(incBy, Db.HashGet(hashKey, entryKey));
}
[Fact]
- public void HashIncerementByLong_ValueExist_EntryIncrementedCorrectValueReturned()
+ public async Task HashIncerementByLong_ValueExist_EntryIncrementedCorrectValueReturned()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
var entryKey = Guid.NewGuid().ToString();
var entryValue = 15;
var incBy = 1;
- Assert.True(Sut.GetDbFromConfiguration().Database.HashSet(hashKey, entryKey, entryValue));
+
+ Assert.True(Db.HashSet(hashKey, entryKey, entryValue));
// act
- var result = Sut.GetDbFromConfiguration().HashIncerementBy(hashKey, entryKey, incBy);
+ var result = await Sut.GetDbFromConfiguration().HashIncerementByAsync(hashKey, entryKey, incBy);
// assert
var expected = entryValue + incBy;
Assert.Equal(expected, result);
- Assert.Equal(expected, Sut.GetDbFromConfiguration().Database.HashGet(hashKey, entryKey));
+ Assert.Equal(expected, await Db.HashGetAsync(hashKey, entryKey));
}
[Fact]
- public void HashIncerementByDouble_ValueDoesntExist_EntryCreatedWithValue()
+ public async Task HashIncerementByDouble_ValueDoesntExist_EntryCreatedWithValue()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
var entryKey = Guid.NewGuid().ToString();
var incBy = 0.9;
+
// act
- Assert.False(Sut.GetDbFromConfiguration().Database.HashExists(hashKey, entryKey));
- var result = Sut.GetDbFromConfiguration().HashIncerementBy(hashKey, entryKey, incBy);
+ Assert.False(Db.HashExists(hashKey, entryKey));
+ var result = await Sut.GetDbFromConfiguration().HashIncerementByAsync(hashKey, entryKey, incBy);
+
// assert
Assert.Equal(incBy, result);
- Assert.True(Sut.GetDbFromConfiguration().HashExists(hashKey, entryKey));
- Assert.Equal(incBy, (double)Sut.GetDbFromConfiguration().Database.HashGet(hashKey, entryKey), 6); // have to provide epsilon due to double error
+ Assert.True(await Sut.GetDbFromConfiguration().HashExistsAsync(hashKey, entryKey));
+ Assert.Equal(incBy, (double)await Db.HashGetAsync(hashKey, entryKey), 6); // have to provide epsilon due to double error
}
[Fact]
- public void HashIncerementByDouble_ValueExist_EntryIncrementedCorrectValueReturned()
+ public async Task HashIncerementByDouble_ValueExist_EntryIncrementedCorrectValueReturned()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
var entryKey = Guid.NewGuid().ToString();
var entryValue = 14.3;
var incBy = 9.7;
- Assert.True(Sut.GetDbFromConfiguration().Database.HashSet(hashKey, entryKey, entryValue));
+
+ Assert.True(Db.HashSet(hashKey, entryKey, entryValue));
// act
- var result = Sut.GetDbFromConfiguration().HashIncerementBy(hashKey, entryKey, incBy);
+ var result = await Sut.GetDbFromConfiguration().HashIncerementByAsync(hashKey, entryKey, incBy);
// assert
var expected = entryValue + incBy;
Assert.Equal(expected, result);
- Assert.Equal(expected, Sut.GetDbFromConfiguration().Database.HashGet(hashKey, entryKey));
+ Assert.Equal(expected, Db.HashGet(hashKey, entryKey));
}
[Fact]
- public void HashScan_EmptyHash_ReturnEmptyCursor()
+ public async Task HashScan_EmptyHash_ReturnEmptyCursor()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
- Assert.True(Sut.GetDbFromConfiguration().Database.HashLength(hashKey) == 0);
+ Assert.True(Db.HashLength(hashKey) == 0);
+
// act
- var result = Sut.GetDbFromConfiguration().HashScan(hashKey, "*");
- // assert
+ var result = await Sut.GetDbFromConfiguration().HashScanAsync(hashKey, "*");
+
+ // assert
Assert.Empty(result);
}
[Fact]
- public void HashScan_EntriesExistUseAstrisk_ReturnCursorToAllEntries()
+ public async Task HashScan_EntriesExistUseAstrisk_ReturnCursorToAllEntries()
{
// arrange
var hashKey = Guid.NewGuid().ToString();
var values =
- Enumerable.Range(0, 1000)
+ Range(0, 1000)
.Select(x => new TestClass