Created
May 29, 2017 06:59
-
-
Save pahud/ea39abd92069ef18d40bc36d7b716458 to your computer and use it in GitHub Desktop.
python sample to test Amazon Elasticache for Redis failover
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import redis, time, datetime, sys | |
endpoint='myred.dpchko.ng.0001.usw2.cache.amazonaws.com' | |
#endpoint='myred-001.dpchko.0001.usw2.cache.amazonaws.com' | |
def prepareConn(endpoint): | |
r = redis.StrictRedis(host=endpoint, port=6379, db=0, socket_timeout=1) | |
return r | |
r = prepareConn(endpoint) | |
while True: | |
print(datetime.datetime.now()) | |
try: | |
print(r.set('foo','bar')) | |
except: | |
print "Unexpected error:", sys.exc_info()[0] | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment