>>> import redis >>> r = redis.Redis(host="172.16.64.175", port=6379, db=0) >>> r.keys() ['foo', 'news:1000:tags', 'c', 'a', 'mylist', 'mycounter', 'mykey', 'b'] >>> r.set('name', 'yang') True >>> r['sex'] = 'man' >>> r.get('sex') 'man' >>> r.delete('a') 1 >>> r.dbsize() 9L >>> r.save() True >>> r.flushdb() True >>> r.keys() [] >>> r.exists('name') False
原文地址:http://blog.csdn.net/callinglove/article/details/43794349