Skip to content

Latest commit

 

History

History

Redis

Redis Connector Sample App

Build Status

This ASP.NET Core sample app uses the Steeltoe Redis Connector to connect to Redis on Cloud Foundry.

This sample uses both Microsoft RedisCache and StackExchange ConnectionMultiplexer to work with the same Redis service.

Pre-requisites - CloudFoundry

  1. Installed Pivotal CloudFoundry
  2. (Optional) installed Windows support
  3. Installed Redis Cache service
  4. Installed .NET Core SDK

Create Redis Service Instance on CloudFoundry

You must first create an instance of the Redis service in a org/space.

  1. cf target -o myorg -s development
  2. cf create-service p-redis shared-vm myRedisService

Publish App & Push to CloudFoundry

  1. cf target -o myorg -s development
  2. cd samples/Connectors/src/Redis
  3. dotnet restore --configfile nuget.config
  4. Publish app to a local directory, specifying the framework and runtime (select ONE of these commands):
    • dotnet publish -f netcoreapp3.1 -r linux-x64
  5. Push the app using the appropriate manifest (select ONE of these commands):
    • cf push -f manifest.yml -p bin/Debug/netcoreapp3.1/linux-x64/publish

Note: The provided manifest will create an app named redis-connector and attempt to bind the app to Redis service myRedisService.

What to expect - CloudFoundry

To see the logs as you startup and use the app: cf logs redis-connector

On a Windows cell, you should see something like this during startup:

2016-07-01T07:27:49.73-0600 [CELL/0]     OUT Creating container
2016-07-01T07:27:51.11-0600 [CELL/0]     OUT Successfully created container
2016-07-01T07:27:54.49-0600 [APP/0]      OUT Running .\Redis
2016-07-01T07:27:57.73-0600 [APP/0]      OUT Hosting environment: development
2016-07-01T07:27:57.73-0600 [APP/0]      OUT Content root path: C:\containerizer\3737940917E4D13A25\user\app
2016-07-01T07:27:57.73-0600 [APP/0]      OUT Now listening on: http://*:57540
2016-07-01T07:27:57.73-0600 [APP/0]      OUT Application started. Press Ctrl+C to shut down.

Upon startup the app inserts a key/values into the bound Redis Cache.

This sample will be available at http://redis-connector.[your-cf-apps-domain]/.

To display those values click on the Cache Data link in the menu and you should see the key/values displayed using the Microsoft RedisCache.

You can click on the ConnectionMultiplexer Data link to view data using the StackExchange CollectionMultiplexer.


See the Official Steeltoe Service Connectors Documentation for a more in-depth walkthrough of the samples and more detailed information