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

Commit 7c6241a

Browse files
committed
Add new Lex operations
1 parent 715d11f commit 7c6241a

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,52 @@ follow [@servicestack](http://twitter.com/servicestack) for updates.
33

44
# C#/.NET Client for Redis
55

6+
### New Lex Operations
7+
8+
The new [ZRANGEBYLEX](http://redis.io/commands/zrangebylex) sorted set operations allowing you to query a sorted set lexically have been added.
9+
A good showcase for this is available on [autocomplete.redis.io](http://autocomplete.redis.io/).
10+
11+
These new operations are available as a 1:1 mapping with redis-server on `IRedisNativeClient`:
12+
13+
```csharp
14+
public interface IRedisNativeClient
15+
{
16+
...
17+
byte[][] ZRangeByLex(string setId, string min, string max, int? skip = null, int? take = null);
18+
long ZLexCount(string setId, string min, string max);
19+
long ZRemRangeByLex(string setId, string min, string max);
20+
}
21+
```
22+
23+
And the more user-friendly APIs under `IRedisClient`:
24+
25+
```csharp
26+
public interface IRedisClient
27+
{
28+
...
29+
List<string> SearchSortedSet(string setId, string start=null, string end=null, int? skip=null, int? take=null);
30+
long SearchSortedSetCount(string setId, string start=null, string end=null);
31+
long RemoveRangeFromSortedSetBySearch(string setId, string start=null, string end=null);
32+
}
33+
```
34+
35+
Just like NuGet version matchers, Redis uses `[` char to express inclusiveness and `(` char for exclusiveness.
36+
Since the `IRedisClient` APIs defaults to inclusive searches, these two APIs are the same:
37+
38+
```csharp
39+
Redis.SearchSortedSetCount("zset", "a", "c")
40+
Redis.SearchSortedSetCount("zset", "[a", "[c")
41+
```
42+
43+
Alternatively you can specify one or both bounds to be exclusive by using the `(` prefix, e.g:
44+
45+
```csharp
46+
Redis.SearchSortedSetCount("zset", "a", "(c")
47+
Redis.SearchSortedSetCount("zset", "(a", "(c")
48+
```
49+
50+
More API examples are available in [LexTests.cs](https://github.com/ServiceStack/ServiceStack.Redis/blob/master/tests/ServiceStack.Redis.Tests/LexTests.cs).
51+
652
### New HyperLog API
753

854
The development branch of Redis server (available when v3.0 is released) includes an ingenious algorithm to approximate the unique elements in a set with maximum space and time efficiency. For details about how it works see Redis's creator Salvatore's blog who [explains it in great detail](http://antirez.com/news/75). Essentially it lets you maintain an efficient way to count and merge unique elements in a set without having to store its elements.

0 commit comments

Comments
 (0)