-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Add support for third-party memcache #600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,16 +16,26 @@ | |
import os | ||
|
||
from flask import Flask | ||
from pymemcache.client.base import Client as MemcacheClient | ||
|
||
import pylibmc | ||
|
||
app = Flask(__name__) | ||
|
||
|
||
# [START client] | ||
memcache_addr = os.environ.get('GAE_MEMCACHE_HOST', 'localhost') | ||
memcache_port = os.environ.get('GAE_MEMCACHE_PORT', 11211) | ||
memcache_client = MemcacheClient((memcache_addr, int(memcache_port))) | ||
# Environment variables are defined in app.yaml. | ||
if os.environ.get('USE_GAE_MEMCACHE'): | ||
MEMCACHE_SERVER = ':'.join( | ||
os.environ.get('GAE_MEMCACHE_HOST', 'localhost'), | ||
os.environ.get('GAE_MEMCACHE_PORT', 11211)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not just check these env vars instead of having a separate env var as a flag? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because eventually these will always be set, and I don't want code that's using third-party memcache to suddenly start using GAE memcache. |
||
else: | ||
MEMCACHE_SERVER = os.environ.get('MEMCACHE_SERVER', 'localhost:11211') | ||
|
||
MEMCACHE_USERNAME = os.environ.get('MEMCACHE_USERNAME') | ||
MEMCACHE_PASSWORD = os.environ.get('MEMCACHE_PASSWORD') | ||
|
||
memcache_client = pylibmc.Client( | ||
[MEMCACHE_SERVER], binary=True, | ||
username=MEMCACHE_USERNAME, password=MEMCACHE_PASSWORD) | ||
# [END client] | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Flask==0.11.1 | ||
gunicorn==19.6.0 | ||
pymemcache==1.3.8 | ||
pylibmc==1.5.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
USE_APPENGINE_MEMCACHE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why prefer that when the GAE env vars all use the "GAE" initialism?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they're inconsistent. change this one or the one in app.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, gotcha. Sorry! Fixed.