1. Installing Redis
Command: sudo pip install Redis
2. Connect to Redis
Import= Redis. Redis ("192.168.86.127", port=6379, db=10)
3. Add 10 data to the list in Indexs
for in range: redis_client.rpush ("indexs", i)
4. View the length of the Indexs key
Llen = Redis_client.llen ("indexs")print'llen: ', Llen
5. Remove a piece of data from a Redis key
Job = Redis_client.lpop ("indexs")print'job: ', Job
6. Get all the data in the Indexs key
Jobs = Redis_client.lrange ('indexs', 0,-1)
7.redis Setting value
Redis_client.hmset ("hot_keys", {"singers":" Hot_singer"}) redis_client.hmset ("hot_keys", {" songs":"hot_song"})
8.redis Get Value
arraykey=["singers","songs"]for in Arraykey: for in redis_client.hmget ("Hot_keys ", key): Print key,line
9.redis get all keys under a certain DB
print Redis_client.keys ()
10.redis Delete a key
Redis_client.delete ('indexs')
Python Simple Operation Redis