1. Setup Python
2. Setup Redis
1 | sudo pip install redis |
Create a small python application to test your connection from Python to Redis
Create a file called redis_test.py in your home directory
Put the following lines of code in this new file.
1 2 3 4 | import redis r = redis.StrictRedis(host = 'localhost' , port = 6379 , db = 0 ) r. set ( 'foo' , 'bar' ) print (r.get( 'foo' )) |
Run the code by typing python redis_test.py
This should return the value for the key ‘foo’ (‘bar’)