Created
June 3, 2016 09:09
-
-
Save tgwizard/51fc191b8e98f52d213a26156c7ad37c to your computer and use it in GitHub Desktop.
Testing ElastiCache redis faiover
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 | |
# -*- coding: utf-8 -*- | |
import os | |
from datetime import datetime | |
from time import time, sleep | |
from redis import StrictRedis | |
client = StrictRedis.from_url(os.environ.get('REDIS_URL')) | |
while True: | |
t = datetime.utcnow().strftime('%H:%M:%S.%f') | |
start = time() | |
try: | |
v = client.get('testing_failover') | |
end = time() | |
print u'%s: Read value %s in %sms' % (t, v, 1000 * (end - start)) | |
except Exception as e: | |
end = time() | |
print u'%s: Got exception %s in %sms' % (t, str(e), 1000 * (end - start)) | |
sleep(0.5) | |
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 | |
# -*- coding: utf-8 -*- | |
import os | |
from datetime import datetime | |
from time import time, sleep | |
from redis import StrictRedis | |
client = StrictRedis.from_url(os.environ.get('REDIS_URL')) | |
while True: | |
t = datetime.utcnow().strftime('%H:%M:%S.%f') | |
start = time() | |
try: | |
v = str(time()) | |
client.set('testing_failover', v) | |
end = time() | |
print u'%s: Set value %s in %sms' % (t, v, 1000 * (end - start)) | |
except Exception as e: | |
end = time() | |
print u'%s: Got exception %s in %sms' % (t, str(e), 1000 * (end - start)) | |
sleep(0.5) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment