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

Commit 6266cb7

Browse files
committed
Merge pull request #159 from fpischedda/master
added missing BitCount method to RedisClient
2 parents df3a9fd + b24783e commit 6266cb7

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

src/ServiceStack.Redis/Commands.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public static class Commands
7878
public readonly static byte[] SetRange = "SETRANGE".ToUtf8Bytes();
7979
public readonly static byte[] GetBit = "GETBIT".ToUtf8Bytes();
8080
public readonly static byte[] SetBit = "SETBIT".ToUtf8Bytes();
81+
public readonly static byte[] BitCount = "BITCOUNT".ToUtf8Bytes();
8182

8283
public readonly static byte[] RPush = "RPUSH".ToUtf8Bytes();
8384
public readonly static byte[] LPush = "LPUSH".ToUtf8Bytes();

src/ServiceStack.Redis/Generic/RedisTypedTransaction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public bool Commit()
101101
queuedCommand.ProcessResult();
102102
}
103103
}
104-
catch (RedisTransactionFailedException e)
104+
catch (RedisTransactionFailedException)
105105
{
106106
rc = false;
107107
}

src/ServiceStack.Redis/RedisNativeClient.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,14 @@ public long SetBit(string key, int offset, int value)
546546
return SendExpectLong(Commands.SetBit, key.ToUtf8Bytes(), offset.ToUtf8Bytes(), value.ToUtf8Bytes());
547547
}
548548

549+
public long BitCount(string key)
550+
{
551+
if (key == null)
552+
throw new ArgumentNullException("key");
553+
554+
return SendExpectLong(Commands.BitCount, key.ToUtf8Bytes());
555+
}
556+
549557
public string RandomKey()
550558
{
551559
return SendExpectData(Commands.RandomKey).FromUtf8Bytes();

src/ServiceStack.Redis/Transaction/RedisTransaction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public bool Commit()
100100
queuedCommand.ProcessResult();
101101
}
102102
}
103-
catch (RedisTransactionFailedException e)
103+
catch (RedisTransactionFailedException)
104104
{
105105
rc = false;
106106
}

tests/ServiceStack.Redis.Tests/Generic/RedisClientTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,13 @@ public void Can_StoreAll_RedisTypedClient()
116116
}
117117

118118
[Test]
119-
public void Can_SetBit_And_GetBit()
119+
public void Can_SetBit_And_GetBit_And_BitCount()
120120
{
121121
const string key = "BitKey";
122122
const int offset = 100;
123123
Redis.SetBit(key, offset, 1);
124124
Assert.AreEqual(1, Redis.GetBit(key,offset));
125+
Assert.AreEqual(1, Redis.BitCount(key));
125126
}
126127

127128
[Test, Explicit]

0 commit comments

Comments
 (0)