Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions django_elasticache/memcached.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Backend for django cache
"""
import logging
import socket
from django.core.cache import InvalidCacheBackendError
from django.core.cache.backends.memcached import PyLibMCCache
Expand Down Expand Up @@ -28,12 +29,14 @@ def update_params(self, params):
"""
update connection params to maximize performance
"""
if not params.get('BINARY', True):
raise Warning('To increase performance please use ElastiCache'
' in binary mode')
if not params.get('binary', True):
self.binary = False
logging.warning('To increase performance please use ElastiCache'
' in binary mode')
else:
params['BINARY'] = True # patch params, set binary mode
if not 'OPTIONS' in params:
self.binary = True

if 'OPTIONS' not in params:
# set special 'behaviors' pylibmc attributes
params['OPTIONS'] = {
'tcp_nodelay': True,
Expand Down Expand Up @@ -67,7 +70,7 @@ def _cache(self):
if client:
return client

client = self._lib.Client(self.get_cluster_nodes)
client = self._lib.Client(self.get_cluster_nodes, binary=self.binary)
if self._options:
client.behaviors = self._options

Expand Down