Python async client for Memcached
Project Links
Meta
Author: Ali-Akber Saifee
Maintainer: Ali-Akber Saifee
Requires Python: >=3.10
Classifiers
Development Status
- 4 - Beta
Intended Audience
- Developers
Operating System
- OS Independent
Programming Language
- Python
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
- Python :: Implementation :: PyPy
memcachio
A pure python async Memcached client with 0 dependencies with support for:
- All memcached commands
- Memcached servers serving on TCP or Unix Domain Sockets
- Memcached clusters
- SSL transport
- SASL Authentication
- Connection reuse for multiple concurrent requests
- Dynamically adjusted connection pooling
- Auto discovery with AWS ElastiCache
Installation
To install memcachio:
$ pip install memcachio
Quick start
Single Node or Cluster client
import asyncio
from memcachio import Client
async def example() -> None:
#: basic client
raw_client = Client(("localhost", 11211))
#: client that decodes the byte responses
decoding_client = Client(("localhost", 11211), decode_responses=True)
# or with a cluster
# cluster_client = Client([("localhost", 11211), ("localhost", 11212)], decode_responses=True)
await raw_client.flushall()
await raw_client.set("foo", b"1")
await raw_client.set("bar", b"2")
assert 2 == await raw_client.incr("foo", 1)
# use the raw client to get a value.
# Note the mapping returned has byte keys
assert (await raw_client.get("foo")).get(b"foo").value == b"2"
# get the values with the decoding client and touch their expiry to be 1 second.
# Note the mapping and the values are strings.
gat_and_touch_many = await decoding_client.gat("foo", "bar", expiry=1)
assert ["2", "2"] == [item.value for item in gat_and_touch_many.values()]
await asyncio.sleep(1)
assert {} == await decoding_client.get("foo", "bar")
asyncio.run(example())
See Client for detailed descriptions of available options when constructing a client.
Compatibility
memcachio is tested against memcached versions 1.6.x
Supported python versions
- 3.10
- 3.11
- 3.12
- 3.13
- PyPy 3.10
- PyPy 3.11
References
0.5.1
Sep 29, 2025
0.5
Sep 22, 2025
0.4.2
Sep 19, 2025
0.4.1
Apr 17, 2025
0.4.0
Apr 17, 2025
0.3
Apr 09, 2025
0.2.0
Apr 01, 2025
0.1.2
Mar 31, 2025
0.1.1
Mar 31, 2025
0.1.0
Mar 31, 2025