Skip to content

Commit

Permalink
Drop memcached setup; require django-redis.
Browse files Browse the repository at this point in the history
  • Loading branch information
mik3y committed Apr 17, 2014
1 parent cced45b commit b0491bf
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 64 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -8,7 +8,6 @@ install:
- pip install --use-mirrors coverage coveralls

services:
- memcache
- redis-server

before_script:
Expand Down
55 changes: 0 additions & 55 deletions bin/setup-kegbot.py
Expand Up @@ -74,9 +74,6 @@
gflags.DEFINE_string('db_database', 'kegbot',
'MySQL/Postgres database name.')

gflags.DEFINE_string('use_memcached', True,
'Configure Kegbot to use memcached. ')


FLAGS = gflags.FLAGS

Expand Down Expand Up @@ -331,57 +328,6 @@ def save(self, ctx):
raise FatalError('Could not create directory "%s": %s' % (self.value, e))


class Memcached(ConfigurationSetupStep):
"""Enable memcached caching layer.
If memcached is installed and available, Kegbot can use it to perform some
operations faster. On Ubuntu, you can install memcached this way:
sudo apt-get install memcached
It's generally a good idea to enable this.
"""
FLAG = 'use_memcached'
HOST = '127.0.0.1:11211' # todo: make configurable
CHOICES = ['yes', 'no']

def get_default(self, ctx):
return ('no', 'yes')[super(Memcached, self).get_default(ctx)]

def validate(self, ctx):
if self.value == 'yes':
self.value = True
if self.value == 'no':
self.value = False
if self.value not in (True, False):
raise ValueError('Please enter "yes" or "no".')

if not self.value:
return

client = None
try:
import memcache
client = memcache.Client([self.HOST])
except ImportError:
try:
import pylibmc
client = pylibmc.Client([self.HOST])
except ImportError:
pass

if not client:
raise ValueError('Memcache client library is not installed. '
'("pip install python-memcached" or "pip install pylibmc")')

if self.value:
ctx['CACHES'] = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': self.HOST,
}
}


class ConfigureDatabase(ConfigurationSetupStep):
"""Select database for Kegbot Server backend.
Expand Down Expand Up @@ -432,7 +378,6 @@ def validate(self, ctx):
RequiredLibraries(),
SettingsDir(),
KegbotDataRoot(),
Memcached(),
ConfigureDatabase(),
]

Expand Down
5 changes: 0 additions & 5 deletions deploy/travis/local_settings.py
@@ -1,6 +1,5 @@
# Kegbot local settings, for travis-ci.org build

# NEVER set DEBUG to `True` in production.
import os

HOME = os.environ['HOME']
Expand All @@ -16,10 +15,6 @@

STATIC_ROOT = KEGBOT_ROOT + '/static'

TIME_ZONE = 'America/Los_Angeles'

CACHES = {'default': {'LOCATION': '127.0.0.1:11211', 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache'}}

SECRET_KEY = 'testkey'

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
Expand Down
7 changes: 5 additions & 2 deletions pykeg/settings.py
Expand Up @@ -147,8 +147,11 @@

CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'cache',
'BACKEND': 'redis_cache.cache.RedisCache',
'LOCATION': '127.0.0.1:6379:1',
'OPTIONS': {
'CLIENT_CLASS': 'redis_cache.client.DefaultClient',
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -33,7 +33,7 @@
'pillow == 2.3.1',
'protobuf == 2.5.0',
'python-gflags == 2.0',
'python-memcached == 1.51',
'django-redis == 3.6.1',
'pytz == 2014.2',
'redis == 2.9.1',
'requests == 2.2.1',
Expand Down

0 comments on commit b0491bf

Please sign in to comment.