/
exists.py
30 lines (23 loc) · 821 Bytes
/
exists.py
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
import redis
import redis_reset
def flush_all():
for port in [6380, 6381, 6382, 6383, 6384]:
redis_reset.flush_each_instance(port)
print;
proxy_pool = redis.ConnectionPool(host='localhost', port=6379)
redis_pool = redis.ConnectionPool(host='localhost', port=6384)
redis_client = redis.Redis(connection_pool = redis_pool)
proxy_client = redis.Redis(connection_pool = proxy_pool)
def exists_test(client):
print 'command: exists';
print 'set key1 hello:\n %s' % client.set('key1','hello')
print 'exists key1:\n %s' % client.exists('key1')
print 'exists key2:\n %s' % client.exists('key2')
if __name__ == '__main__':
flush_all()
d = {'redis':redis_client,'proxy':proxy_client}
for i in d:
print '%s-->\t'% (i),
exists_test(d[i])
print '\n'
flush_all()