Skip to content

Instantly share code, notes, and snippets.

@ggendre
Created November 14, 2012 14:36
Show Gist options
  • Save ggendre/4072478 to your computer and use it in GitHub Desktop.
Save ggendre/4072478 to your computer and use it in GitHub Desktop.
connect to a reddis server from a python instance on dotcloud
"""
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