varco-memcached
Memcached cache backend for the varco framework.
MemcachedCache implements varco_core.cache.CacheBackend on top of
aiomcache. Values are serialized
(JSON by default) and stored in Memcached; TTL is enforced natively via
Memcached's exptime.
Installation
uv add varco-memcached
# or: pip install varco-memcached
Requires a running Memcached server (memcached -p 11211).
Quick start
from varco_memcached import MemcachedCache, MemcachedCacheSettings
settings = MemcachedCacheSettings(host="localhost", port=11211, key_prefix="myapp:")
cache = MemcachedCache(settings)
await cache.start()
await cache.set("user:42", {"name": "Ada"}, ttl=300)
value = await cache.get("user:42") # {"name": "Ada"}
await cache.stop()
Configuration
MemcachedCacheSettings reads from environment variables under the
VARCO_MEMCACHED_CACHE_ prefix (kept separate from any Redis settings in the
same process):
| Field | Default | Env var |
|---|---|---|
host |
"localhost" |
VARCO_MEMCACHED_CACHE_HOST |
port |
11211 |
VARCO_MEMCACHED_CACHE_PORT |
pool_size |
2 |
VARCO_MEMCACHED_CACHE_POOL_SIZE |
key_prefix |
"" |
VARCO_MEMCACHED_CACHE_KEY_PREFIX |
settings = MemcachedCacheSettings.from_env()
Key differences from varco_redis.RedisCache
- Keys must be
bytes—aiomcacherequires byte keys;varco_memcachedencodes the prefixed key as UTF-8 internally. - No native key enumeration. Memcached has no
SCAN-equivalent command.clear()only removes keys written by thisMemcachedCacheinstance in the current process (tracked in an in-process registry) — keys written by other processes, or surviving a restart, are unaffected and expire via TTL. Use the server'sflush_all()for a full flush (affects every client sharing that server). - No native
exists(). It performs agetand checks forNone— a full round trip, though deserialization is skipped. - TTL semantics differ. Memcached's
exptimeof0means "never expire" — the opposite convention from a bare RedisSETwith no TTL. - Key length limit. Memcached rejects keys over 250 bytes or containing
whitespace/control characters —
MemcachedCacheSettings.memcached_key()does not validate this; callers are responsible for keeping keys short.
DI integration
Unlike scan-only event bus backends, MemcachedCache needs an async
start() call to open its connection pool — wiring goes through
MemcachedCacheConfiguration, a providify @Configuration:
from providify import DIContainer
from varco_core.cache import CacheBackend
from varco_memcached.di import async_bootstrap
container = await async_bootstrap() # installs MemcachedCacheConfiguration
cache = await container.aget(CacheBackend) # started MemcachedCache singleton
await cache.set("key", "value", ttl=60)
await container.ashutdown() # stops the cache via @PreDestroy
Or manually:
from providify import DIContainer
from varco_memcached.cache import MemcachedCacheConfiguration
container = DIContainer()
await container.ainstall(MemcachedCacheConfiguration)
cache = await container.aget(CacheBackend)
Override settings by registering a higher-priority @Provider before
ainstall() (equal-priority bindings resolve first-registered):
from providify import Provider
@Provider(singleton=True)
def memcached_cache_settings() -> MemcachedCacheSettings:
return MemcachedCacheSettings(host=os.environ["MEMCACHED_HOST"], key_prefix="myapp:")
container.provide(memcached_cache_settings)
await container.ainstall(MemcachedCacheConfiguration)
Running tests
uv run pytest varco_memcached/tests/
Metadata
Release files for varco-memcached 3.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| varco_memcached-3.2.0.tar.gz | 49.4 kB | With provenance | Details for varco_memcached-3.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| varco_memcached-3.2.0-py3-none-any.whl | Python 3 | none | any | Details for varco_memcached-3.2.0-py3-none-any.whl |
Total release size: 86.7 kB
Release files / varco_memcached-3.2.0.tar.gz
| Download URL | varco_memcached-3.2.0.tar.gz |
|---|---|
| Size | 49.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf45f4e9094518d14386a48cacffd354f4fd63355556c770f1bfcfc0e927c473
|
|
BLAKE2b-256 checksum How to use checksums |
0bdf58e9abd223eac52de43b8236675a6a7e362ffce1e617dd38e58eb9d6cfe9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.
Transparency logRelease files / varco_memcached-3.2.0-py3-none-any.whl
| Download URL | varco_memcached-3.2.0-py3-none-any.whl |
|---|---|
| Size | 37.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d57bc2eab7c13cc8b827232893210e21d420e0401915f41787713e856e7aec87
|
|
BLAKE2b-256 checksum How to use checksums |
40c8520d5d4aab401a78c979a1d9ccb824ac2dfd2ad70e2f6be0fce25181054e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.
Transparency logSecurity for varco-memcached 3.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for varco_memcached-3.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.