, , , ,

redis – Installation and Simple Test using redis-py in Ubuntu

Installation

Redis is a fast key value store developed by Salvatore Sanfilippo (antirez).
Redis can be viewed as a next level memcached server. It is easy to install and has lots of cool features.

Ubuntu Repository Installation

# standard ubuntu repository installs an old redis version - redis 2.4.15
sudo apt-get install -y redis-server

Installation from rowan wookey’s PPA

# latest redis binary via a ppa from rowan wookey(rwky) - installs redis 2.6.12
sudo add-apt-repository -y ppa:rwky/redis
sudo apt-get update -y
sudo apt-get install -y redis-server

redis-py – Python Client for Redis

redis-py – python client for redis

sudo pip install redis

redis-test.py

create redis.py test file in the shell – copy & paste


cat > redis-test.py <<-"_EOF_"
# -*- coding: utf-8 -*-
import redis
pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
r = redis.Redis(connection_pool=pool)
result = r.set('foo', 'bar')
print(result)
#True
result=r.get('foo')
print(result)
#'bar'
_EOF_

python redis-test.py
#True
#bar

References

1. redis home: http://redis.io
2. redis-py Github repository: https://github.com/andymccurdy/redis-py
3. redis-py documentation: http://redis-py.readthedocs.org/en/latest/
4. redis installation in ubuntu: http://askubuntu.com/questions/88265/how-to-find-the-latest-version-of-redis-server-in-repos