Skip to content

Instantly share code, notes, and snippets.

@tgwizard
Created June 3, 2016 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgwizard/51fc191b8e98f52d213a26156c7ad37c to your computer and use it in GitHub Desktop.
Save tgwizard/51fc191b8e98f52d213a26156c7ad37c to your computer and use it in GitHub Desktop.
Testing ElastiCache redis faiover
#!/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)
#!/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