Introduction
Client libraries help your programs talk to Redis easily without you needing to know all the details of how Redis works.
client = RedisClient() client.connect() client.command(arguments) client.disconnect()
client = RedisClient() client.connect() client.set('key', 'value') client.get('key') client.disconnect()
client = RedisClient() client.connect() client.incr('counter') client.get('counter') client.disconnect()
client = RedisClient() client.connect() client.set('greeting', 'hello') result = client.get('greeting') client.disconnect() print(result)
client = redis.Redis(host='localhost', port=6379)
client.set('key', 'value')
result = client.get('key')result?client = redis.Redis(host='localhost', port=6379)
client.set('count', 'foo')
client.incr('count')incr line. What is the likely cause?incr works only if the key holds a string representing an integer.set('count', 'foo') stores 'foo' as string, but 'foo' is not a valid integer string, so incr fails.incr command requires the key to hold a string representing an integer. -> Option BPass the test and this pattern moves unknown