I have explained the installation of Redis server in my previous post. Now I will explain a simple program to connect to the Redis server and perform Read/Write operations.
For interacting with Redis, we need a python package redis. This can be installed using pip.
pip install redis
You can also download and install the latest release from the github repository
Now lets write the program
import redis # create the redis connection r_conn = redis.Redis( host='localhost', port=6379) # create a key-value pair with key as name and value as "amalgjose" r_conn.set('name', 'amalgjose') # retrieve the value by using the key value = r_conn.get('name') print("Value from Redis -->", value)
Execute the program and see whether the value is getting printed properly.