- Release Notes (3.0 onwards; earlier releases)
Overview
StackExchange.Redis is a high performance general purpose redis client for .NET languages (C#, etc.). It is the logical successor to BookSleeve, and is the client developed-by (and used-by) Stack Exchange for busy sites like Stack Overflow. For the full reasons why this library was created (i.e. “What about BookSleeve?”) please see here.
Features
- 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”
Installation
StackExchange.Redis can be installed via the nuget UI (as StackExchange.Redis), or via the nuget package manager console:
PM> Install-Package StackExchange.Redis
Documentation
- Server - running a redis server
- Authentication - connecting to a Redis server with user authentication
- Basic Usage - getting started and basic usage
- Async Timeouts - async timeouts and cancellation
- Configuration - options available when connecting to redis
- Client-side geographic failover (Active-Active / “multi-DB client”) - connecting to multiple redundant Redis endpoints for high availability
- 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
- Compare-And-Swap / Compare-And-Delete (CAS/CAD) - atomic conditional operations using value comparison
- Events - the events available for logging / information purposes
- Pub/Sub Message Order - advice on sequential and concurrent processing
- Pub/Sub Key Notifications - how to use keyspace and keyevent notifications
- Hot Keys - how to use
HOTKEYSprofiling - Using RESP3 - information on using RESP3
- ServerMaintenanceEvent - how to listen and prepare for hosted server maintenance, including the server-native notifications sent by Redis Enterprise and Redis Cloud (known elsewhere as smart client handoffs or hitless upgrades)
- Streams - how to use the Stream data type
- Arrays - how to use Redis Arrays as sparse arrays of values
- Vector Sets - how to use Vector Sets for similarity search with embeddings
- Hash Import - bulk-importing many hashes that share a common set of field names
- Hash Tags and Slots - co-locating keys in the same cluster slot for multi-key operations
- Cluster slot statistics - per-slot usage statistics via
CLUSTER SLOT-STATS - Where are
KEYS/SCAN/FLUSH*? - how to use server-based commands - Profiling - profiling interfaces, as well as how to profile in an
asyncworld - Scripting - running Lua scripts, including the low-allocation
ScriptEvalLeaseAPI - Ad-hoc commands - running commands without a dedicated API, including the low-allocation
ExecLeaseAPI - Command coverage - which server commands the library does not expose, and why
- Testing - running the
StackExchange.Redis.Testssuite to validate changes - Timeouts - guidance on dealing with timeout problems
- Thread Theft - guidance on avoiding TPL threading problems
- Sync over async - why blocking on an async redis call starves the thread-pool, and what to do
- RESP Logging - capturing and validating RESP streams
- Analyzer rules - the
SER3xxsuggestions reported by the analyzer shipped in the package
Questions and Contributions
If you think you have found a bug or have a feature request, please report an issue, or if appropriate: submit a pull request. If you have a question, feel free to contact me.