cachelib
A collection of cache libraries in the same API interface.
What it is and what it does
CacheLib is a cache abstraction library that presents a single, consistent API for seven different cache backends. Instead of writing code tied to Redis or Memcached directly, you instantiate a cache object (RedisCache, MemcachedCache, SimpleCache, etc.) and use the same get/set/delete methods regardless of the backend. It was extracted from Werkzeug and is maintained by the Pallets Ecosystem.
The library supports both local caching (SimpleCache for single-process in-memory, FileSystemCache for disk) and distributed backends (Redis, Memcached, MongoDB, DynamoDB, Valkey, uWSGI). This makes it useful for applications that need to switch cache strategies without refactoring—for example, using SimpleCache in development and RedisCache in production.
Use it for:
- Swap cache backends in a Flask or web application without changing application logic.
- Implement a local development cache (SimpleCache) that scales to Redis in production.
- Cache expensive database queries or API responses using a consistent interface.
- Store session data or temporary state across multiple processes using a shared backend.
- Reduce coupling between application code and a specific caching technology.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
CacheLib provides a unified API for interacting with multiple cache backends—Redis, Memcached, MongoDB, DynamoDB, file system, in-memory, uWSGI, and Valkey—so you can swap implementations without changing application code.
Yes. CacheLib is actively maintained, has no security vulnerabilities, zero runtime dependencies, and low install friction. It solves a real problem—cache backend abstraction—and is part of the trusted Pallets Ecosystem. Install it if you need flexible caching or plan to support multiple backends.
Install
cachelib on PyPI
pip
pip install cachelibuv
uv add cachelibpoetry
poetry add cachelibInstalling cachelib
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained—last commit 2026-08-12, released 2026-08-08, part of the Pallets Ecosystem.
License in practice
BSD-3-Clause (permissive): you may use, modify, and distribute this package freely in commercial and private projects, provided you include the license notice.
Quickstart
pip install cachelib
from cachelib import SimpleCache
cache = SimpleCache()
cache.set("key", "value")
print(cache.get("key")) # Output: value
Python 3.11 or later required. Backend-specific clients (redis, pymongo, etc.) must be installed separately if using non-local backends.
Verify before relying
- Whether backend clients (redis, pymongo, etc.) are optional or required for specific cache types to function.
- Performance characteristics and memory overhead of SimpleCache vs. external backends under load.
- Whether type hints cover all public methods and backend-specific parameters.
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 6 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 19,272,987/month — #1,070 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cachelib-0.15.4-py3-none-any.whl
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
aiocacheProvides asyncio-compatible caching with…
unclear · top 5,000 on PyPI
fastapi-cache2Caches FastAPI endpoint and function results…
permissive · top 5,000 on PyPI
cashewsAsync cache framework with decorator and direct…
permissive · top 15,000 on PyPI
Flask-CachingFlask-Caching adds caching support to Flask…
permissive · top 5,000 on PyPI
python-memcachedPure Python client library for connecting to…
permissive · top 5,000 on PyPI
pylibmcpylibmc is a Python client for memcached, the…
permissive · top 15,000 on PyPI
aiohttp-client-cacheAdds transparent request caching to…
permissive · top 15,000 on PyPI
simplekvsimplekv provides a unified key-value storage…
permissive · top 15,000 on PyPI
BeakerBeaker provides session management and caching…
permissive · top 15,000 on PyPI
django-valkeyProvides a Valkey cache and session backend for…
permissive · top 15,000 on PyPI