skillfed

cachelib

A collection of cache libraries in the same API interface.

cachelib v0.15.4 19.3M downloads/30d#1,070 on PyPI161
Permissive license BSD-3-Clause Active released

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 cachelib

uv

uv add cachelib

poetry

poetry add cachelib

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonTyping :: Typed

Tags

cache abstraction layermulti-backend cachingredis memcached wrapperunified cache interfacecache backend abstractiondistributed cache clientin-memory cache library
cache-abstractionmulti-backendpallets-ecosystem

More Database packages