StackExchange.Redis Client libraries
At the time of writing there are two popular and actively developed C# client libraries for Redis available:
- ServiceStack.Redis – created by Demis Bellot of ServiceStack fame and based on Miguel de Icaza’s redis-sharp project,
- BookSleeve – mantained by Mark Gravell and as I understand used by Stack Exchange.
Before making a choice I would suggest trying both of them and deciding which API and capabilities better suit your project.
BookSleeve has non-blocking (asynchronous) API, provides thread-safe connection object, while ServiceStack implementation provides JSON serialization, connection pool like client factory and uses convention to simplify POCO object persistence.
In this article I will use ServiceStack.Redis, but remember that BookSleeve has been proved in a big real-world web application and is also very capable.
StackExchange.Redis is a high performance general purpose redis client for .NET languages (C# etc).
- High performance multiplexed design, allowing for efficient use of shared connections from multiple calling threads
- Abstraction over redis node configuration: the client can silently negotiate multiple redis servers for robustness and availability
- Convenient access to the full redis feature-set
- Full dual programming model both synchronous and asynchronous usage, without requiring “sync over async” usage of the TPL
- Support for redis “cluster”
StackExchange.Redis can be installed via the nuget UI (as StackExchange.Redis), or via the nuget package manager console:
PM> Install-Package StackExchange.Redis
If you require a strong-named package (because your project is strong-named), then you may wish to use instead:
PM> Install-Package StackExchange.Redis.StrongName
(for further reading, see here)
- Basic Usage – getting started and basic usage
- Configuration – options available when connecting to redis
- Pipelines and Multiplexers – what is a multiplexer?
- Keys, Values and Channels – discusses the data-types used on the API
- Transactions – how atomic transactions work in redis
- Events – the events available for logging / information purposes
- Pub/Sub Message Order – advice on sequential and concurrent processing
- Where are KEYS / SCAN / FLUSH*? – how to use server-based commands
- Profiling – profiling interfaces, as well as how to profile in an async world
- Scripting – running Lua scripts with convenient named parameter replacement