diff --git a/NewLife.Redis/NewLife.Redis.csproj b/NewLife.Redis/NewLife.Redis.csproj
index 75b932f..8dc5648 100644
--- a/NewLife.Redis/NewLife.Redis.csproj
+++ b/NewLife.Redis/NewLife.Redis.csproj
@@ -56,7 +56,7 @@
-
+
diff --git a/NewLife.Redis/RedisSortedSet.cs b/NewLife.Redis/RedisSortedSet.cs
index 673966e..9360f38 100644
--- a/NewLife.Redis/RedisSortedSet.cs
+++ b/NewLife.Redis/RedisSortedSet.cs
@@ -25,6 +25,12 @@ public class RedisSortedSet : RedisBase
/// 添加到有序集合的成员数量,不包括已经存在更新分数的成员
public Int32 Add(T member, Double score) => Execute((rc, k) => rc.Execute("ZADD", Key, score, member), true).ToInt(-1);
+ /// 添加元素并指定分数,返回添加到集合的成员数量
+ /// 元素
+ /// 分数
+ /// 添加到有序集合的成员数量,不包括已经存在更新分数的成员
+ public Int32 Add(T member, Int64 score) => Execute((rc, k) => rc.Execute("ZADD", Key, score, member), true).ToInt(-1);
+
/// 批量添加,返回添加到集合的成员数量
///
///
@@ -41,6 +47,22 @@ public class RedisSortedSet : RedisBase
return Execute((rc, k) => rc.Execute("ZADD", args.ToArray()), true).ToInt(-1);
}
+ /// 批量添加,返回添加到集合的成员数量
+ ///
+ ///
+ /// 添加到有序集合的成员数量,不包括已经存在更新分数的成员
+ public Int32 Add(IEnumerable members, Int64 score)
+ {
+ var args = new List
-
+
diff --git a/Test/Test.csproj b/Test/Test.csproj
index c89e947..5a5f202 100644
--- a/Test/Test.csproj
+++ b/Test/Test.csproj
@@ -16,7 +16,7 @@
-
+
diff --git a/XUnitTest/SortedSetTests.cs b/XUnitTest/SortedSetTests.cs
index 7ba7d52..71843a8 100644
--- a/XUnitTest/SortedSetTests.cs
+++ b/XUnitTest/SortedSetTests.cs
@@ -190,6 +190,32 @@ public class SortedSetTests
Assert.Equal(33.44, zset.GetScore("stone"));
}
+ [Fact]
+ public void Add_xx2()
+ {
+ var rkey = "zset_add_xx2";
+
+ // 删除已有
+ _redis.Remove(rkey);
+
+ var zset = new RedisSortedSet(_redis, rkey);
+
+ // 插入数据
+ var ticks = DateTime.Now.Ticks;
+ zset.Add("stone", ticks);
+ zset.Add("stone1", ticks);
+ Assert.Equal(2, zset.Count);
+
+ var r = zset.GetScore("stone");
+ var r1 = zset.GetScore("stone2");
+ var r2 = zset.Execute((r, k) => r.Execute("ZSCORE", zset.Key, "stone"), false);
+
+ Assert.Equal(ticks, r);
+ Assert.Equal(0, r1);
+ Assert.NotEmpty(r2);
+ Assert.NotEqual("0", r2);
+ }
+
[Fact]
public void Add_nx()
{
diff --git a/XUnitTest/XUnitTest.csproj b/XUnitTest/XUnitTest.csproj
index 48ded6e..c9c0acb 100644
--- a/XUnitTest/XUnitTest.csproj
+++ b/XUnitTest/XUnitTest.csproj
@@ -9,11 +9,11 @@
-
-
+
+
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive