Redis is a key-value store that is fast, sits in memory and runs on many different platforms. Installing on Windows isn’t straightforward from the Redis site, so below are the steps I use to get going.
1. Download the latest .zip from: https://github.com/mythz/redis-windows/tree/master/downloads
2. Extract these files to a folder (I did f:\redis)
3. In a command prompt, run
(from your directory above).
Redis should now be running on port 6379. You can change this in redis.windows.conf if you’d like.
4. Start a new Visual Studio Project (I’m using c# / .net 4.5).
5. In Package Manager Console (NuGet) let’s install the client, run:
6. Include using StackExchange.Redis;
7. Now you can use the below to save and get values:
//setup your connection ConnectionMultiplexer redisConn = ConnectionMultiplexer.Connect("localhost"); //get your db IDatabase redDb = redisConn.GetDatabase(); //save a key & val redDb.StringSet("testKey", "test val"); //get a key & val Console.WriteLine(redDb.StringGet("testKey"));
This is just start of what Redis can do, find more at the official Redis site.
3 thoughts on “How To Install Redis on Windows and Get Started With C#”
[…] How To Install Redis on Windows and Get Started With C# […]
I think you need to add this command: redisConn.Close();. If not, you have to restart Redis to be able to connect again.
LikeLiked by 1 person