pymemcache
A comprehensive, fast, pure Python memcached client
What it is and what it does
pymemcache is a pure-Python client library for memcached that implements the complete memcached text protocol. It provides flexible connection options (TCP over IPv4/IPv6 or UNIX sockets), configurable socket timeouts, and access to memcached's noreply flag for write optimization. The library includes modular serialization and deserialization, optional error-as-cache-miss handling, and supports both single-client and pooled/hashed cluster patterns.
Because it is pure Python with no compiled dependencies, it integrates well with async frameworks like gevent. It is maintained by Pinterest and used in production at scale. The latest version (4.0.0) dropped Python 2 and 3.6 support, added type hints, and introduced pluggable compression serialization.
Use it for:
- Cache layer for web applications using Django 3.2+ (built-in backend) or other frameworks needing distributed caching.
- Cluster-aware caching with HashClient for consistent hashing across multiple memcached nodes.
- Async-compatible caching in gevent-based applications where C extensions are not viable.
- High-throughput write scenarios using noreply mode to reduce round-trip latency.
- Custom serialization workflows via flexible serde interface for domain-specific data types.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pure-Python memcached client implementing the complete text protocol with support for TCP (IPv4/IPv6) and UNIX sockets, configurable timeouts, and optional noreply mode for faster writes.
Yes, with conditions. Install if you need a pure-Python memcached client for Django 3.2+, gevent integration, or custom serialization. The library is stable and widely used, but maintenance is aging (last release 2022-10-17). Suitable for production use; verify that your Python version is 3.7+ and that you have memcached infrastructure in place.
Install
pymemcache on PyPI
pip
pip install pymemcacheuv
uv add pymemcachepoetry
poetry add pymemcacheInstalling pymemcache
Before you install
Low friction: pure Python wheel with no runtime dependencies. Aging maintenance status—last release was 2022-10-17, though the repository remains active with recent commits and no archived status.
License in practice
Apache License 2.0 (permissive) allows commercial use, modification, and distribution with minimal restrictions, making it suitable for most projects.
Quickstart
pip install pymemcache
from pymemcache.client.base import Client
client = Client(('localhost', 'port'))
client.set(b'key', b'value')
result = client.get(b'key')
Requires a running memcached server accessible at the specified host and port.
Verify before relying
- Current performance characteristics relative to other pure-Python memcached clients in modern workloads.
- Extent of typing coverage added in version 4.0.0 and whether it covers the full public API.
- Whether pluggable compression serde (added in 4.0.0) is production-ready and documented.
- Specific port number or connection defaults for typical memcached deployments.
Package facts
| License | Apache License 2.0 (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 1,397 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,981,655/month — #2,802 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pymemcache-4.0.0-py2.py3-none-any.whl
Keywords: memcache, client, database
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
pylibmcpylibmc is a Python client for memcached, the…
permissive · top 15,000 on PyPI
python-memcachedPure Python client library for connecting to…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-pymemcacheAdds OpenTelemetry tracing instrumentation to…
permissive · top 5,000 on PyPI
aiomcacheAsyncio-based memcached client providing…
permissive · top 15,000 on PyPI
pmd-pytcpA pure-Python TCP/IP stack (Ethernet through…
copyleft · top 15,000 on PyPI
clamav-clientA Python client library for the ClamAV…
copyleft · top 15,000 on PyPI
aiocacheProvides asyncio-compatible caching with…
unclear · top 5,000 on PyPI
google-cloud-memcacheA Python client library for creating and…
permissive · top 1,000 on PyPI
icmplibicmplib provides a pure Python implementation…
copyleft · top 5,000 on PyPI