Should we stop recommending pylibmc?

The caching docs recommend using pylibmc or pymemcache for caching using memcached.

However, there’s an exception swallowed on startup under Python 3.13 that has been fixed since July 2024, but there hasn’t been a pylibmc release since 2022.

Granted, the situtation with pymemcache isn’t significantly better (no releases in 3 years either, but at least their CI does target py313, albeit with a version of gevent that is too old to compile in the test requirements).

So I have to wonder out loud: should we stop recommending pylibmc without better maintenance?

4 Likes

+1 for me, definitely not recommending anything that is not touched for a few years.

I’ve never used memcached though. I’m wondering if there are any other alternatives for python clients?

1 Like

python-memcached has a release supporting 3.12 from Jan 2024, and their CI also tests against 3.13.

1 Like

Reading up on the history, the Django backend for python-memcached was deprecated in Django 3.2 and removed in 4.1. It’s unfortunate that now it might be in one of the better maintenance postures. Maybe that counsels against deprecating anything else.

We should do something about referencing that library in our docs. An alternative is to reference pylibmc2 which is a new fork. The person who created it is the one who is offering to help maintain pylibmc. They just haven’t heard back/gotten access.

2 Likes

Another alternative would be to “deprioritize” or “de-emphasize” the use of memcached as the cacheing engine, preferring instead to recommend one of the other options.

2 Likes

That fork is only five commits ahead of the upstream fork, with a bunch of release tooling updates. At a glance, it doesn’t look like there’s anything shady there, but it would be nice to know of folks using it in production and verifying that’s it’s not malware before we recommend it.

We should do something before the Django 7.0 branch is cut in January. If no one can vouch for pylibmc2, I think we need to deprecate all of the memcached clients, and we should do that in Django 6.2.

mxamin, the maintainer of pylibmc2, has been working on another open source package for a while. I think it’s probably fine to maintain. Another option is to fork it into Django’s org or Django Commons.

I think we just need the lights to be kept on for this package. There is some clean up that can be done (remove py2.7, swap out nose, etc), but it seems largely fine as is.

cc-ing @steering_council for others to chime in with thoughts. This is becoming a priority for us quickly.

Yep, I think we should at least deemphasise. (Possibly even warn against.)

IIRC from recent surveys most folks are using either DB or Redis (or compatible) backends. We should point there, in the main.

I’m not aware that there are folks who have capacity to pick up maintenance here—keeping the lights on is more than it sounds if we’re about more than just one time updates—so I’d be sceptical about making a move that falsely signals otherwise. (But maybe there are folks…?)

The topic of memcached support came up again for the Steering Council meeting of Monday, 5 October 2026.

We’re pretty sure that Django can’t really be continuing to recommend memcached, and in the first position at that, (docs) if neither of the two backend libraries are supported.

So, more or less this. With December coming, we need to make a judgement call.

I know @timgraham, you’ve at least been looking around this situation, so you can probably give an insight, maybe? (Sorry for the noise if not!)

Memcached itself still has regular activity but if there’s no supported Python client then moving it down, or removing it, maybe be something we want to think about medium term anyway?

1 Like

Hi all,

I’ve been using Django for many years and until recently, I had no need for a cache. Only when I started using Django Ratelimit did I have to familiarize myself with caching and pick a cache backend that meets the requirements given in the Django Ratelimit docs. Please understand that I’m writing this as someone who has barely any experience with caching in web apps at all, so forgive me if I’ve overlooked something obvious.

My first stop for this was, as always, the Django docs: Django’s cache framework. This page presents the available backends and their pros and cons well. I’ve read it several times in an attempt to pick the backend that works best for me.

Django Ratelimit requires a cache backend that is shared across all processes and servers and that implements atomic increments. According to its docs, Redis and Memcached are the officially supported backends; the database backend is explicitly ruled out, as it does not support atomic increments. (The note below cache.decr() in the Django docs points in the same direction.)

I think this matters for the suggestion to point people to the DB or Redis backends instead: for use cases like mine, the DB backend is not an option. Without Memcached, Redis would be the only one left.

Maybe I’ve not tried hard enough and I’m almost sure I’ve missed something. But Redis felt to me like yet another third-party dependency, and one that has been a bit unsteady lately: two license changes since 2024 plus a change of maintainers. I’m also not sure where the project is headed. (All I wanted to implement was rate limiting, not something with AI cloud context analysis.) :wink:

Memcached?

sudo apt install memcached

Done.

(Yes, with the bindings and cross-server operation there is more to it, but basically it works just like that.)

As for the bindings, which I understand are the actual problem here: we have been running pymemcache 4.0.x on Python 3.12 in production for eight months now, without any problems. I realize that this says nothing about who will maintain it in the future, but maybe it helps as a data point.

To sum it up:

Memcached is easy to install and easy to use, and it is the only backend that meets the requirements above while being a cache and nothing else. For my use case, that combination is unique.

I understand your arguments, and I’m sure there are other solutions, possibly Redis. But I chose Memcached deliberately, after studying and weighing my options, and if it was removed (or just considered a second-class backend), the best of them would be gone.

Therefore, I would like to ask you to reconsider whether demoting Memcached is really the right way forward.

2 Likes

I appreciate the desire to have more things maintained upstream. Another option is to move it out of core into a separate package, so it wouldn’t be gone. You’d still be able to use it. Though you’d need to sort out the python connector library since that’s the crux of the problem.

And you always have the option to pull the code directly into your project and maintain it yourself. The cache backend is an interface that’s meant to be extended.


@carltongibson @jacobtylerwalls if forks of the connection libraries moved into Django Commons, would that make it more appealing? I forgot about that as an option in the meeting :sweat_smile:

As a pure sidebar - not that this really helps anything - but your comment about the database backend not supporting incr made me curious.

I found these two tickets explaining some background and details:

I found them interesting. It looks like it wouldn’t be too hard to add it to a custom version.

Side note apt install redis works too - and the default options have served me well. The only setting I always set is maxmemory.
There’s also valkey if you want something “not-redis” but fully compatible. (That’s actually what I use on my production server.)

Since I use redis/valkey for a couple of different functions (it’s also my channels layer) I actually have one less package I need to install/maintain by not using memcached.

3 Likes

I have no actual desire to remove memcached. I think it would be a shame.

The issue (as I understand it) is that the client libraries are unmaintained. I struggle to see that we can recommend it in that circumstance.

Moving a client library to Django Commons is neither necessary nor sufficient for resolving that.

Not necessary because all we need is to know that someone is keeping at least one of the client libraries on the road. Not sufficient because moving or forking one in Django Commons doesn’t of itself provide that person.

It comes back to Jacob’s “if someone will vouch, that’s enough” from up thread.

If a fork is needed to enable someone to do the job then by all means.

(Looking at this, I do think the ORM DB cache should be listed first: it’s perfect for many scenarios, takes zero set up, and is something folks can grow out of when they need to, but that’s off topic probably.)

Oh, I thought both had maintainers today, but different problems.

Forking pymemcached there (assuming Tim Graham is on board) allows him to actually cut releases and continue to maintain it.

And pylibmc2 is a fork from a person who has volunteered to be a maintainer, but isn’t a well known person in the Django community. Moving that to DC avoids a similar situation where a library ends up blocked by a person who is unresponsive to transition the package.

I’ve misunderstood to ask if that’s the case. There’s only urgency here if the packages are unmaintained. (A new user comes to Django, they go to caching, and the top suggested option doesn’t in fact work, is the case we need to avoid.)

Both packages have people who are willing to help, they just lack permissions. Tim can merge PRs for the one, but can’t release to pypi. The other, the person forked to implement their changes, with the goal that they’d be upstreamed.

I’m not sure “maintainer” is the appropriate word since they can’t release new versions of the original packages, but people are interested in helping according to the acitivity.

We brought this up during the office hours and talked through what take to get these binding libraries over to Django Commons and determined it doesn’t eliminate the uncertainty around them. We landed on de-emphasising it in the docs to start is the best next step. And like we mentioned in the SC meeting, we should begin moving the backend it to a separate django package that can be installed with an extra.

We can still work to find better homes, or forks for these various libraries because we’d still want to support django[memcached].

Sorry for that roundabout, but I’m back on track now :rocket:

Tim, it appears you mixed up a couple of libraries. Just to summarize:

  1. pymemcache
  • Used by django.core.cache.backends.memcached.PyMemcacheCache
  • Maintained by Pinterest
  • No new release sine 2022. However, it’s not obvious to me that a new release is needed to solve any problems.
  • Has commits through July 2025
  1. python-memcached - maintained by Sean Reifschneider (linsomniac).
  • Used by django.core.cache.backends.memcached.MemcachedCache (deprecated in Django 3.2 and removed in Django 4.1)
  • This is a ticket requesting to readd this backend since the problems in python-memcached were fixed and a new release issued in Dec 2023/Jan 2024. There have been no releases since. However, it’s not obvious to me that one is needed now.
  • I have commit permissions for this library. I think I asked for them when I was a Django fellow and this library appeared inactive. I have merged some cleanups in recent months (mainly from Tim S.) because I thought it would help Django. I didn’t realize the Django backend for this library was removed.
  • After Carlton pinged me in this thread the other today, I was about to contact Sean to ask for PyPI permissions until I realized the backend is removed from Django.
  • If the backend were added back to Django, I am willing to pursue this further and try to keep the lights on for this package. I could also try to add other Django community members as maintainers so there is a greater bus factor.

Although I have no personal or professional need for memcache at this time, I agree with Carlton that removing the memcache backends or demoting them to separate packages would be a shame. At least anecdotally according to this thread, pymemcache seems to work well with Django. Perhaps it’s stable software that doesn’t require frequent updates.

5 Likes

@timgraham Ah, I did mix up pymemcache and python-memcached! Thank you for correcting me and the breakdown.

The concern is around keeping the test suite updated with the versions of Python that Django supports. In this case, neither pymemcache or pylibmc (what PyLibMCCache uses) run tests against 3.14+.

I have merged some cleanups in recent months (mainly from Tim S.) because I thought it would help Django.

I honestly thought that was the “right” package :sweat_smile:

I’ll open a PR to update pymemcache’s test suite include 3.14 (now that I know the correct repo). If that can get merged in, this all becomes much less of a concern.

I agree with Carlton that removing the memcache backends or demoting them to separate packages would be a shame

Agreed on removing them outright, I don’t want to see that.

Moving them, I don’t see that as such a bad thing. django[memcached] gives it a reasonable amount of official-ness. And being in a separate package would provide us with the flexibility to make decisions more rapidly than the Django release cadence allows.