Memorandum
The below codes is how to use redis via Python.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
import redis
r = redis.StrictRedis(host='localhost', port=6379)
r.set('test1', 'aiueo') r.expire('test1', 1000) print r.get('test1')
r.set('test2', 2) print r.get('test2')
print r.exists('test1') print r.exists('test0')
keys = r.keys('test*') if len(keys) > 0 : for key in keys: print '--------------------------------------------' print key print r.get(key) print r.type(key) print r.ttl(key)
r.append('test1', '_kkkkkkk') print r.get('test1')
r.delete('test1') print r.exists('test1')
|
Thanks.