Using a9s Redis for PCF

This topic describes how to use a9s Redis for PCF after it has been successfully installed. For more information, see the Installing and Configuring a9s Redis for PCF topic.

Use a9s Redis for PCF with an App

To use a9s Redis for PCF with an app, create a service instance and bind the service instance to your app. For more information about managing service instances, see Managing Service Instances with the cf CLI.

View the a9s Redis for PCF Service

After the tile is installed, you can see the a9s-redis32 and its service plans appear in your PCF marketplace. Run cf marketplace to see the service listing:

$ cf marketplace
Getting services from marketplace in org test / space test as admin...
OK
service      plans                                           description
a9s-redis32  redis-single-small, redis-single-big            This is the anynines Redis 32 service.

For more information about available service plans, see Configure Service Plans.

Create a Service Instance

To provision a Redis database, run cf create-service. For example.

$ cf create-service a9s-redis32 redis-single-small my-redis-service

Depending on your infrastructure and service broker utilization, it might take several minutes to create the service instance.

Run the cf services command to view the creation status. This command displays a list of all your service instances. To view the status of a specific service instance, run cf service NAME-OF-YOUR-SERVICE.

Bind an App to a Service Instance

After your database is created, run cf bind-service to bind the service to your app:

$ cf bind-service a9s-redis-app my-redis-service

Restage or Restart Your App

To enable your app to access the service instance, run cf restage or cf restart to restage or restart your app.

Obtain Credentials for Accessing Your Service Instance

After a service instance is bound to an app, the credentials of your Redis database are stored in the environment variables of the app. Run cf env APP-NAME to display the environment variables.

You can find the credentials in the VCAP_SERVICES key.

$ cf env a9s-redis-app
Getting env variables for app a9s-redis-app in org test / space test as admin...
OK

System-Provided:
{
 "VCAP_SERVICES": {
  "a9s-redis": [
   {
    "credentials": {
     "host": "EXAMPLE-HOST",
     "password": "EXAMPLE-PWD",
     "port": 6379
    },
    "label": "a9s-redis",
    "name": "my-redis-service",
    "plan": "redis-single-non-persistent-small",
   }
  ]
 }
}
...

You can use the host and password values to connect to your database with a Redis client.

Delete a a9s Redis for PCF Service Instance

WARNING: Before deleting a service instance, you must backup data stored in your database. This operation cannot be undone and all the data is lost when the service is deleted.

Before you can delete a service instance, you must unbind it from all apps.

List Available Services

Run cf services to list available services.

$ cf services

Getting services in org test / space test as admin...
OK

name                 service       plan                   bound apps        last operation
my-redis-service     a9s-redis     redis-single-small     a9s-redis-app     create succeeded

This example shows that my-redis-service is bound to the a9s-redis-app app.

Unbind a Service Instance

Run cf unbind-service to unbind the service from your app:

$ cf unbind-service a9s-redis-app my-redis-service

Delete a Service Instance

After unbinding the service, it is no longer bound to an app. Run cf delete-service to delete the service:

$ cf delete-service my-redis-service

It might take several minutes to delete the service. Deleting a service deprovisions the corresponding infrastructure resources. Run the cf services command to view the deletion status.

Upgrade the Service Instance to another Service Plan

Once created, you can upgrade your service instance to another, larger service plan. A larger service plan provides more CPU, RAM and storage. For more information, see Update a Service Instance of the Managing Service Instances with the cf CLI.

$ cf update-service my-redis-service -p a-bigger-plan

Here are the plans you can upgrade to depending on the one you are currently using:

  • If you are currently using the redis-single-smallplan, you can upgrade to redis-single-bigplan.

Change RDB Persistence Settings

a9s Redis for PCF supports RDB persistence with point in time snapshots. This setting can be changed by the user.

Default behavior

Setting Effect
save 900 1 Create a snapshot after 900 seconds if 1 write operations occurred.
save 300 10 Create a snapshot after 300 seconds if 10 write operations occurred.
save 60 10000 Create a snapshot after 300 seconds if 10 write operations occurred.

Configuring RDB

You can configure RDB according to the needs of your apps by providing customer settings. This setting must follow the original Redis configuration for RDB -c {"snapshot": "['save 900 1', 'save 300 10']"}.

  $ cf update-service my-redis-service -c {"snapshot": "['save 900 1', 'save 300 10']"}

In this example, it configures to snapshot the Redis database according to the following rules:

Setting Effect
save 900 1 Create a snapshot after 900 seconds if 1 write operations occurred.
save 300 10 Create a snapshot after 300 seconds if 10 write operations occurred.

Cache Only

You can disable snapshots and use Redis as cache only by creating the service with the following customer setting -c '{"snapshot": "[]"}'.

The command is:

  $ cf update-service my-redis-service -c {"snapshot": "[]"}

For more information, see the snapshot settings in the documentation of Redis Persistence.

Add a Graphite Endpoint

If you want to monitor your service with Graphite, you can set an endpoint to where to information will be sent with the cf update-service command. This command expects the -c flag and a JSON string containing the graphite and metrics_prefix keys.

$ cf update-service my-redis-service -c '{ "graphite": ["yourspace.your-graphite-endpoint.com:12345"], "metrics_prefix": "your-api-key.my-redis" }'

Add a Syslog Endpoint

The cf update-service command used with the -c flag can let you stream your syslog to a third-party service. In this case, the command expects a JSON string containing the syslog key.

$ cf update-service my-redis-service -c '{ "syslog": ["logs4.your-syslog-endpoint.com:54321"] }'
Create a pull request or raise an issue on the source for this page in GitHub