Quick Setup of Redise Cloud
The steps here are super simple and go as follows:
- Sign up for a Redise Cloud account here or here .
- Setup a subscription
- Setup a database
- Create some sample code to test out the database
- Show your coworkers what you did and how awesome you are
Create a New Subscription
Now that you have signed in, let’s add a subscription to your account, if you do not already have one. Click on the + icon as shown in the screenshot below.
Select a Location and Subscription Type
You are given options to choose which cloud provider/region and the name.
For this quickstart, I am going select the Standard, 30MB free subscription, but realize it has the fewest features. Fortunately it is super simple to change your subscription as you grow. For more information on the specifics of the Plans, please go to the Create Subscription page.
Be aware that many of the features you see on the right side are not available in the free version.
Setup a Database
Name the database and for the moment, accept the default settings.
You will see a spinning circle in the top right as the DB is created. Once it turns to a green check, then the database is created and ready.
The important part that is on this page is the Endpoint information. That is our entry point to this database.
As a quick smoke test, you could telnet to your assigned endpoint and port, then do the redis PING command. You should see something like this:
# telnet redis-19836.c9.us-east-1-2.ec2.cloud.redislabs.com 19836 Trying 22.214.171.124... Connected to redis-19836.c9.us-east-1-2.ec2.cloud.redislabs.com. Escape character is '^]'. PING +PONG
While that works, it would actually be best to load the redis-cli command line utility for future use. Not only does it have a lot of great features that you will use to manage your Redis database, it allows you to give the redis password, which you should have.
$ redis-cli -h redis-19836.c9.us-east-1-2.ec2.cloud.redislabs.com -p 19836 -a astrongpassword redis-19836.c9.us-east-1-2.ec2.cloud.redislabs.com:19836> PING PONG
You can usually get redis-cli and other command line redis tools through your favorite package manager or by installing redis locally.
Reading and Writing Data with redis-py
Once we have tested the connection to your Redis database, you can start reading and writing data. The following code snippet writes the value bar to the Redis key foo, reads it back, and prints it. I chose python, but you could use your favorite language.
You first need to install the redis client library for python if you do not have it already.
$ sudo pip install redis
Next cut and place this into a file:
#import the library
# Create connection object
r = redis.Redis(
# set a value for the foo object
# retrieve and print the value for the foo object
Now run the code:
$ python example_redis.py bar
With that simple test complete, if you have existing code or app that uses redis, just change the host, port, password and SSL certificates and you are done.
For more in-depth information on options with databases, etc. Please go here.
For more examples of other programming languages, please see the left nav menu.