The .NET Community has built many client libraries to help handle requests to Redis Server. In this guide, we'll mostly be concerned with using the StackExchange.Redis client library. As the name implies the StackExchange client is developed by StackExchange for use on popular websites like StackOverflow.
There are a few ways to Install the Package:
- .NET CLI
- PM Console
- Package Reference
- NuGet GUI
Run the following in the directory of the
csproj file you want to add the package too.
Run the following command from the Package Manager Console
You can also add the package directly to you
csproj file with the following XML:
If you're using Visual Studio, and you want to use the NuGet GUI just follow the steps outlined by Microsoft, and make sure to search for StackExchange.Redis
The ConnectionMultiplexer is the main arbiter of the connection to Redis inside the CLR, your application should maintain a single instance of the ConnectionMultiplexer throughout its runtime. You can initialize the Multiplexer with either a connection string, or with a
ConfigurationOptions object. A typical connection string is of the form:
HOST_NAME is the host name of your server (e.g.
PORT_NUMBER is the port number Redis is listening on (e.g.
PASSWORD is your redis server's password (e.g.
Once we have a handle for the Multiplexer, we need get a connection to the database.
Now that you've retreived the connection to the database, all that's left is to use it. Here are some simple operations:
- Ping the Database
- Set and Get String
- List Operations
- Set Operations
- Hash Operations
Redis Launchpad is like an “App Store” for Redis sample apps. You can easily find apps for your preferred frameworks and languages. Below are few of these apps. Click here to access the complete lists of apps