Skip to content

Instantly share code, notes, and snippets.

@mikeyk
Created December 21, 2011 23:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeyk/1508150 to your computer and use it in GitHub Desktop.
Save mikeyk/1508150 to your computer and use it in GitHub Desktop.
""" Run with:
gunicorn -k gevent -b 0.0.0.0:8080 test_mc:app
or
gunicorn -k sync -b 0.0.0.0:8080 test_mc:app
"""
import memcache as memcache
# toggle to try pylibmc instead
# import pylibmc as memcache
client = memcache.Client(["127.0.0.1:11222", "127.0.0.1:11223"])
def app(environ, start_response):
keys = []
for i in range(0, 50):
keys.append('key:%d' % i)
client.get_multi(keys)
status = '200 OK'
response_headers = [
('Content-type','text/plain'),
('Content-Length', str(len('OK')))
]
start_response(status, response_headers)
return iter(['OK'])
if __name__ == '__main__':
for i in range(0, 50):
client.set("key:%d" % i, "a" * 5000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment