Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 7db48fb

Browse files
committed
Add new Hyperlog commands
1 parent 3bcb997 commit 7db48fb

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

src/ServiceStack.Redis/Commands.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ public static class Commands
8686
public readonly static byte[] Match = "MATCH".ToUtf8Bytes();
8787
public readonly static byte[] Count = "COUNT".ToUtf8Bytes();
8888

89+
public readonly static byte[] PfAdd = "PFADD".ToUtf8Bytes();
90+
public readonly static byte[] PfCount = "PFCOUNT".ToUtf8Bytes();
91+
public readonly static byte[] PfMerge = "PFMERGE".ToUtf8Bytes();
92+
8993
public readonly static byte[] RPush = "RPUSH".ToUtf8Bytes();
9094
public readonly static byte[] LPush = "LPUSH".ToUtf8Bytes();
9195
public readonly static byte[] RPushX = "RPUSHX".ToUtf8Bytes();
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using NUnit.Framework;
2+
3+
namespace ServiceStack.Redis.Tests
4+
{
5+
[TestFixture, Explicit]
6+
public class RedisHyperLogTests
7+
: RedisClientTestsBase
8+
{
9+
[Test]
10+
public void Can_Add_to_Hyperlog()
11+
{
12+
var redis = new RedisClient("10.0.0.64");
13+
redis.FlushAll();
14+
15+
redis.AddToHyperLog("hyperlog", "a", "b", "c");
16+
redis.AddToHyperLog("hyperlog", "c", "d");
17+
18+
var count = redis.CountHyperLog("hyperlog");
19+
20+
Assert.That(count, Is.EqualTo(4));
21+
22+
redis.AddToHyperLog("hyperlog2", "c", "d", "e", "f");
23+
24+
redis.MergeHyperLogs("hypermerge", "hyperlog", "hyperlog2");
25+
26+
var mergeCount = redis.CountHyperLog("hypermerge");
27+
28+
Assert.That(mergeCount, Is.EqualTo(6));
29+
}
30+
}
31+
}

tests/ServiceStack.Redis.Tests/ServiceStack.Redis.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@
192192
<Compile Include="Generic\RedisTypedPipelineTests.cs" />
193193
<Compile Include="RedisClientEvalTests.cs" />
194194
<Compile Include="RedisClientsManagerExtensionsTests.cs" />
195+
<Compile Include="RedisHyperLogTests.cs" />
195196
<Compile Include="RedisPipelineCommonTests.cs" />
196197
<Compile Include="RedisPipelineTests.cs" />
197198
<Compile Include="Examples\BestPractice\IBlogRepository.cs" />

0 commit comments

Comments
 (0)