Skip to content

Instantly share code, notes, and snippets.

@pahud
Created May 29, 2017 06:59
Show Gist options
  • Save pahud/ea39abd92069ef18d40bc36d7b716458 to your computer and use it in GitHub Desktop.
Save pahud/ea39abd92069ef18d40bc36d7b716458 to your computer and use it in GitHub Desktop.
python sample to test Amazon Elasticache for Redis failover
#!/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