Using Service Connectors with Redis Cache
This tutorial takes you through setting up a .NET Core application with the Redis service connector.
Note
For more detailed examples, please refer to the Redis project in the Steeltoe Samples Repository.
First, start a Redis instance using the Steeltoe dockerfile.
docker run --publish 6379:6379 steeltoeoss/redis
Next, create a .NET Core WebAPI that interacts with Redis
Create a new ASP.NET Core WebAPI app with the Steeltoe Initializr
Name the project "RedisConnector"
Add the "Redis" dependency
Click Generate to download a zip containing the new project
Extract the zipped project and open in your IDE of choice
Set the instance address in appsettings.json
{ "redis": { "client": { "host": "127.0.0.1", "port": "6379" } }
Tip
Looking for additional params to use when connecting? Have a look at the docs
Run the application
dotnet run <PATH_TO>\RedisConnector.csproj
Navigate to the endpoint (you may need to change the port number) http://localhost:5000/api/values
Once the app loads in the browser you will see the 2 values that were written and retrieved from Redis. "[123,456]"