Redis Cloud is a fully-managed cloud service for hosting and running Redis datasets. The service provides developers with a highly-available, scalable and performant database-as-a-service that is ideally suited to scalable web and mobile app. For Cloud Foundry developers building and hosting apps on Pivotal Web Services, you can now add Redis Cloud to your apps directly from the Services Marketplace.
Click on the Redis Cloud service to see the Plan Selection page:
Choose a plan to start with (I recommend starting with the Free 25MB plan) and select the ‘BUY THIS PLAN’ button to create the service instance. You can also choose to bind it to a specific application. If you aren’t ready to bind the RedisDB to your app right now, you can always bind it later from the application dashboard or through the command line interface (CLI).
Command Line Interface
If you’re more inclined to use the command line interface, here are the steps:
First, create the service:
$ cf create-service rediscloud PLAN_NAME INSTANCE_NAME
PLAN_NAME is the plan you want to use and
INSTANCE_NAME is the name you want to use for the service. Once the service’s instance is created, bind it to your application with the following command:
$ cf bind-service APP_NAME INSTANCE_NAME
APP_NAME is the name of the application that the service will be bound to.
That’s all there is to it—your first database will be created automatically, and your app will now be able to use Redis Cloud. You can obtain the immutable endpoint (hostname and port) of your Redis Cloud database by fetching the contents of your app’s
VCAP_SERVICES environment variable, or from the service’s management console (click the ‘MANAGE’ link in under the Redis Cloud service). Depending on the plan you purchased, you can also use the management console to edit the properties of your database.
Redis Cloud is fully compliant with the open source Redis project, so all you need to do is point your application to your Redis Cloud endpoint and you’re good to go. For example, if you’re using Ruby, create an intializer file (e.g. config/initializers/redis.rb) with the following content:
rediscloud_service = JSON.parse(ENV[‘VCAP_SERVICES’])[“rediscloud-n/a”]
credentials = rediscloud_service.first[“credentials”]
$redis = Redis.new(:host => credentials[“hostname”], :port => credentials[“port”], :password => credentials[“password”])
That’s all that’s needed to get you started so you can focus on developing your application instead of worrying about things like:
- node failures (our service boasts automatic and transparent failover),
- scaling up or down (that’s done seamlessly, instantly and without interruption to the service),
- data persistence (included free of charge),
- daily and on-demand backups (also included), or
- any other operational aspect regarding your Redis database.
About the AuthorMore Content by Nima Badiey