>>> import redis
>>> r = redis.Redis(host='localhost', port=6379, db=0)
>>> r.set('foo', 'bar')
True
>>> r.get('foo')
'bar'
>>> r.delete('foo')
True
>>> r.dbsize()
0
>>> r['test']='OK!'
>>> r.save()
True
--------------------------------
>>> r.flushdb()
True
>>> a
>>> dir(a)
['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
>>> r.exists('chang')
False
>>> r.keys()
['aaa', 'test', 'bbb', 'key1']
其他命令API,请参照redis-Python作者的博客,写的挺清楚了:
https://github.com/andymccurdy/redis-py