9951 explained code solutions for 126 technologies


python-redisSimple Redis example


import redis

r = redis.Redis()
r.set('k', 'hi')
print(r.get('k').decode('utf-8'))ctrl + c
import redis

import Redis module

redis.Redis

connect to Redis server

r.set

sets value by key in Redis

'k'

name of the key to set value

'hi'

value we set for our key

r.get('k')

get our key value from Redis

decode('utf-8')

convert Redis bytes to utf-8 string