Created
April 18, 2018 12:18
-
-
Save vinitkumar/e044e6556f285c8eb6d5eecfd1d990db to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import redis | |
import random | |
import time | |
r = redis.StrictRedis(host='localhost', port=6379, db=0) | |
def write_to_redis_million_times(): | |
for i in range(1000000): | |
ramdom_int_list = random.sample(range(len(range(100))), 10) | |
r.set('post_{}'.format(i), ramdom_int_list) | |
start_time = time.time() | |
write_to_redis_million_times() | |
end_time = time.time() | |
print("time it look to complete a million writes to redis %0.2fs" % (end_time - start_time)) | |
for i in range(100): | |
print(r.get('post_{}'.format(i))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment