Created
November 14, 2012 14:36
-
-
Save ggendre/4072478 to your computer and use it in GitHub Desktop.
connect to a reddis server from a python instance on dotcloud
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is how to connect to a reddis server from a python instance on dotcloud | |
This assume that you have something like this in your dotcloud.yml | |
data: | |
type: redis | |
And that you added "redis" to the list in your requirements.txt pip file. | |
""" | |
import json | |
with open('/home/dotcloud/environment.json') as f: | |
env = json.load(f) | |
import redis | |
r = redis.from_url(env['DOTCLOUD_DATA_REDIS_URL'], db=0) | |
r.set('foo', 'bar') | |
// True | |
r.get('foo') | |
// 'bar' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment