Skip to content

Commit

Permalink
Revert "fix wsgi"
Browse files Browse the repository at this point in the history
This reverts commit d3335d6.
  • Loading branch information
maximz committed Mar 31, 2016
1 parent d3335d6 commit da33b2a
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 14 deletions.
5 changes: 2 additions & 3 deletions course_selection/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise

application = DjangoWhiteNoise(get_wsgi_application())

# https://devcenter.heroku.com/articles/memcachier#django
# Fix django closing connection to MemCachier after every request (#11331)
from django.core.cache.backends.memcached import BaseMemcachedCache
BaseMemcachedCache.close = lambda self, **kwargs: None

application = DjangoWhiteNoise(get_wsgi_application())
BaseMemcachedCache.close = lambda self, **kwargs: None
84 changes: 73 additions & 11 deletions settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@
'DJANGO_SECRET_KEY', 'asdfasfshjkxhvkzjxhiu1012u4-9r0iojsof')


MEMCACHED_SETTINGS = {
def get_cache():
try:
environ['MEMCACHE_SERVERS'] = environ[
'MEMCACHIER_SERVERS'].replace(',', ';')
environ['MEMCACHE_USERNAME'] = environ['MEMCACHIER_USERNAME']
environ['MEMCACHE_PASSWORD'] = environ['MEMCACHIER_PASSWORD']
return {
'default': {
# Use pylibmc
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',

Expand Down Expand Up @@ -68,18 +75,73 @@
'retry_timeout': 2,
'dead_timeout': 10
}
},
'courses': {
# Use pylibmc
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',

# Use binary memcache protocol (needed for authentication)
'BINARY': True,

# TIMEOUT is not the connection timeout! It's the default expiration
# timeout that should be applied to keys! Setting it to `None`
# disables expiration.
'TIMEOUT': None,

'OPTIONS': {
# Enable faster IO
'no_block': True,
'tcp_nodelay': True,

# Keep connection alive
'tcp_keepalive': True,

# Timeout for set/get requests
'_poll_timeout': 2000,

# Use consistent hashing for failover
'ketama': True,

# Configure failover timings
'connect_timeout': 2000,
'remove_failed': 4,
'retry_timeout': 2,
'dead_timeout': 10
}
},
'courseapi': {
# Use pylibmc
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',

def get_cache():
try:
environ['MEMCACHE_SERVERS'] = environ[
'MEMCACHIER_SERVERS'].replace(',', ';')
environ['MEMCACHE_USERNAME'] = environ['MEMCACHIER_USERNAME']
environ['MEMCACHE_PASSWORD'] = environ['MEMCACHIER_PASSWORD']
return {
'default': MEMCACHED_SETTINGS,
'courses': MEMCACHED_SETTINGS,
'courseapi': MEMCACHED_SETTINGS
# Use binary memcache protocol (needed for authentication)
'BINARY': True,

# TIMEOUT is not the connection timeout! It's the default expiration
# timeout that should be applied to keys! Setting it to `None`
# disables expiration.
'TIMEOUT': None,

'OPTIONS': {
# Enable faster IO
'no_block': True,
'tcp_nodelay': True,

# Keep connection alive
'tcp_keepalive': True,

# Timeout for set/get requests
'_poll_timeout': 2000,

# Use consistent hashing for failover
'ketama': True,

# Configure failover timings
'connect_timeout': 2000,
'remove_failed': 4,
'retry_timeout': 2,
'dead_timeout': 10
}
}
""",'memcache': {
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
'TIMEOUT': 500,
Expand Down

0 comments on commit da33b2a

Please sign in to comment.