memcached: Switch from pylibmc to python-binary-memcached.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-05-09 13:23:33 -07:00
committed by Tim Abbott
parent 15ffd2b666
commit dbdf67301b
13 changed files with 41 additions and 84 deletions

View File

@@ -4,7 +4,7 @@ import random
from datetime import datetime
from typing import Any, Callable, Dict, List, Mapping, Sequence, Tuple
import pylibmc
import bmemcached
import ujson
from django.conf import settings
from django.contrib.sessions.models import Session
@@ -79,13 +79,9 @@ def clear_database() -> None:
# With `zproject.test_settings`, we aren't using real memcached
# and; we only need to flush memcached if we're populating a
# database that would be used with it (i.e. zproject.dev_settings).
if default_cache['BACKEND'] == 'django_pylibmc.memcached.PyLibMCCache':
pylibmc.Client(
[default_cache['LOCATION']],
binary=True,
username=default_cache["USERNAME"],
password=default_cache["PASSWORD"],
behaviors=default_cache["OPTIONS"],
if default_cache['BACKEND'] == 'django_bmemcached.memcached.BMemcached':
bmemcached.Client(
(default_cache['LOCATION'],), **default_cache['OPTIONS'],
).flush_all()
model: Any = None # Hack because mypy doesn't know these are model classes