Search code examples
c#redisbooksleeve

Options for performing ZINTERSTORE with Booksleeve?


I've been using Booksleeve as my redis driver in C# and have been quite happy with it - but I have come across the need to do some work with sorted sets. It appears that these only have minimal support within Booksleeve - there are no implementations of commands like ZUNIONSTORE or ZINTERSTORE, for example.

I have found scobrown's fork of Booksleeve on Github which claims to have implemented these operations, but I've been using the "official" package from NuGet and I'm unsure about switching to another fork instead.

Has anyone had experience with using this fork? Is it stable, and reliable enough for production code?

Otherwise, has anyone come up with any other work-arounds for needing to do things like intersections or unions on sorted sets? I've been doing something like the following:

var set = await conn.SortedSets.Range(db, firstSet, 0, -1);
set = set.Intersect(await conn.SortedSets.Range(db, secondSet, 0, -1));
set = set.Intersect(await conn.SortedSets.Range(db, thirdSet, 0, -1));

which has the obvious disadvantage of needing to retrieve the full contents of the sets one at a time, and perform the intersection using .NET's IEnumerable<>.Intersect() instead of doing it within redis. Is there a better way?


Solution

  • I have merged in johanalkemad's branch which includes SortedSets.UnionAndStore and SortedSets.IntersectAndStore. Build 1.1.0.9 has been pushed to NuGet.