Skip to content

Commit

Permalink
removed memcached
Browse files Browse the repository at this point in the history
  • Loading branch information
maximz committed Mar 31, 2016
1 parent 2eb1ae8 commit b960892
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 60 deletions.
6 changes: 0 additions & 6 deletions course_selection/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,4 @@
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise


# 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())
55 changes: 1 addition & 54 deletions settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,64 +36,12 @@
'DJANGO_SECRET_KEY', 'asdfasfshjkxhvkzjxhiu1012u4-9r0iojsof')


MEMCACHED_SETTINGS = {
# 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
}
}

"""
,'memcache': {
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
'TIMEOUT': 500,
'BINARY': True,
'OPTIONS': {
'tcp_nodelay': True
}
}
"""


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
}
except:
return {
'default': {
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
Expand All @@ -111,7 +59,7 @@ def get_cache():
'TIMEOUT': 60 * 60
}
}
"""
except:
# local memory caches
return {
'default': {
Expand All @@ -125,7 +73,6 @@ def get_cache():
}

}
"""

CACHES = get_cache()

Expand Down

0 comments on commit b960892

Please sign in to comment.