We removed our free Sandbox April 25th.
You can read more on our blog.

Redis

Note

CLI Command examples on this page are always provided without the --application (shorthand -A) argument, assuming you’re running these commands in a connected folder (at creation or using the dotcloud connect command). For more details on connected folders, see Migrating to the CLI 0.9.

dotCloud features Redis 2.4.11. If you don’t know Redis yet, the great docs and awesome tutorials are available at http://redis.io/.

Basics

If your application requires a Redis data store for caching or other purposes, all you need to do is add the following lines to your dotcloud.yml Build File (dotcloud.yml):

data:
  type: redis

Note

You can give your database or cache service any name you like instead of “data”. If for some reason your application needs multiple databases, you can either use multiple independant services (by repeating the database section multiple times in dotcloud.yml, each with a different name instead of just “db”), or create multiple users and databases inside one single service. The first option (multiple services) will bring more resources, but keep in mind that when you go to production, this will generally incur higher costs as well.

Your data service will be globally available. This means that you can use it with applications running on other platforms.

If for some reason, you want to use dotCloud just to deploy a standalone data service, create a two-line “dotcloud.yml” file in an empty directory, and from this directory, just run:

dotcloud create mynicedb
dotcloud push
dotcloud info data

In less than one minute, your data service will be up and running, and the dotcloud info command will show its connection credentials.

Configure Your Application

There are two ways to configure your app to use your new data service:

  • manually, by hard-coding the host, port, user and password;
  • automatically, by retrieving those parameters from the Environment File.

Manual Configuration

Check your service parameters using dotcloud info:

dotcloud info data

Using environment.json

When your application is built by the dotCloud platform, a file named environment.json is created in the home directory of each of your services.

This file contains a JSON-formatted dictionary with most of the configuration information of the services in your stack. You can use it to retrieve the host, port, and password, of your databases, caches, and so on.

You will find snippets of code to retrieve the connection information of your databases in the Environment Guide.

Your ramen.data service will expose the following variables:

  • DOTCLOUD_DATA_REDIS_HOST
  • DOTCLOUD_DATA_REDIS_LOGIN
  • DOTCLOUD_DATA_REDIS_PASSWORD
  • DOTCLOUD_DATA_REDIS_PORT
  • DOTCLOUD_DATA_REDIS_URL

Note that DATA will be replaced by the (upper-cased) name of your service.

Redis CLI

To start playing with Redis (or for debugging purposes), you can get a Redis shell. Using the password shown by dotcloud info, with the following command:

dotcloud run data redis-cli

In the newly opened redis shell, type the following:

AUTH <password>

You can then use standard Redis commands.