Skip to content
Researched developer tool comparisonsPrices dated · vendor sources linked · no star ratings
Search

Stage 03 · Host · Researched comparison

Best Python Caching Libraries in 2026

cachetools is the first pick for most Python developers who need a small, dependency-free in-memory cache with TTL and LRU eviction. It suits single-process apps, scripts and tests. For a shared cache across processes or servers, use redis-py or pymemcache. For framework-level caching inside a web app, Django's built-in cache framework and Flask-Caching cover the common cases without adding a separate service.

By
Published 27 Nov 2026 · 8 tools compared

We run no ads and no affiliate links at launch. The order of a list follows our published method. See how we score.

Prices are the starting prices vendors list publicly. Plans change, so confirm the current price on the vendor page before you buy.

Key takeaways

  • cachetools is free, open source and pure Python, with no external service to run.
  • redis-py and pymemcache are free clients, but you pay for or host the Redis or Memcached server yourself.
  • Django's cache framework and Flask-Caching are free and ship caching as part of the web stack.
  • None of these libraries send your data to a third party; caching happens in your process or on a server you control.

Who each pick is for

Comparison

The 8 tools at a glance
ToolBest forStandout featureListed starting priceFree plan or trial
1cachetoolsIn-process caches with TTL and LRU evictionPure Python with no dependenciesFree (open source)Free plan
2redis-pyShared caching backed by a Redis serverOfficial Redis client for PythonFree (open source)Free plan
3pymemcacheA pure Python client for MemcachedNo C dependencies, so it installs easilyFree (open source)Free plan
4Django cache frameworkCaching inside Django web applicationsBuilt into Django with no extra packageFree (open source)Free plan
5Flask-CachingAdding a cache layer to Flask appsSimple setup through a Cache objectFree (open source)Free plan
6dogpile.cacheCaching with locking and expiration policiesRegion-based API with pluggable backendsFree (open source)Free plan
7diskcachePersistent caches stored on local diskStores cache on disk so it survives restartsFree (open source)Free plan
8aiocacheAsync caching in asyncio applicationsAsync API with memory, Redis and Memcached backendsFree (open source)Free plan

How we picked

We picked libraries that are actively maintained and genuinely solve caching in Python. Criteria were fit for the job, supported platforms, licence and price, whether data stays local or goes to a server you control, and the main limits such as per-process scope or a required backend. Sources are vendor pages, official documentation and project repositories. Prices and plans change, so confirm details on the vendor site before you commit.

The tools, one by one

01

cachetools

Best for in-process caches with TTL and LRU eviction

Visit github.com
cachetools homepage
cachetools homepage, captured Nov 2026

What it is and where it fits

cachetools provides dict-like cache classes for Python. You get LRUCache, LFUCache, TTLCache, FIFOCache and MRUCache, plus decorators such as cached and cachedmethod. It runs on any platform that supports Python and installs from PyPI with pip install cachetools. The project is MIT licensed.

The main limit is scope: a cachetools cache exists inside a single process. If you run several workers, each has its own copy, so hit rates drop and data can diverge. It also does not persist across restarts. Skip it when you need a shared cache across servers; reach for Redis or Memcached instead.

Standout: Pure Python with no dependencies

Pricing pointer

Free (open source), as listed by the vendor (cachetools website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Pure Python with no dependencies
  • includes LRU, LFU, TTL, FIFO and MRU cache classes

Drawbacks

  • Cache lives in one process only
  • no built-in persistence or cross-process sharing

Skip it if this limit matters to you: cache lives in one process only.

Verdict. A sensible pick for in-process caches with TTL and LRU eviction.

Alternatives in this guide: redis-py, pymemcache, Django cache framework

02

redis-py

Best for shared caching backed by a Redis server

Visit github.com
redis-py homepage
redis-py homepage, captured Nov 2026

What it is and where it fits

redis-py is the official Python client for Redis. You use it to store cached values as strings, hashes or other Redis types, with expiry set per key. It supports connection pooling, pipelines and asyncio. The library is MIT licensed and installs from PyPI.

The client is free, but the cache needs a Redis server. You can run Redis yourself or use a managed service, which has its own pricing. Memory is finite, so set maxmemory and an eviction policy or keys will accumulate. Use redis-py when several processes or machines must share cached data and you already run Redis.

Standout: Official Redis client for Python

Pricing pointer

Free (open source), as listed by the vendor (redis-py website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Official Redis client for Python
  • supports TTL, pipelining and connection pooling

Drawbacks

  • Requires a running Redis server
  • you manage that server and its memory limits

Skip it if this limit matters to you: requires a running Redis server.

Verdict. A sensible pick for shared caching backed by a Redis server.

Alternatives in this guide: cachetools, pymemcache, Django cache framework

03

pymemcache

Best for a pure Python client for Memcached

Visit github.com
pymemcache homepage
pymemcache homepage, captured Nov 2026

What it is and where it fits

pymemcache is a pure Python client for Memcached, maintained under the Pinterest organisation. It offers a client with connection pooling, configurable timeouts and support for the text and binary protocols. It installs from PyPI and is Apache 2.0 licensed.

Like redis-py, the client is free but the server is separate. Memcached stores only simple key-value data, with no persistence and no built-in replication. That makes pymemcache a fit for straightforward object caching where losing the cache on restart is acceptable. Skip it if you need data structures beyond strings or durable storage.

Standout: No C dependencies, so it installs easily

Pricing pointer

Free (open source), as listed by the vendor (pymemcache website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • No C dependencies, so it installs easily
  • supports pooling and timeouts

Drawbacks

  • Needs a Memcached server
  • Memcached has no persistence and limited data types

Skip it if this limit matters to you: needs a Memcached server.

Verdict. A sensible pick for A pure Python client for Memcached.

Alternatives in this guide: cachetools, redis-py, Django cache framework

04

Django cache framework

Best for caching inside Django web applications

Visit docs.djangoproject.com
Django cache framework homepage
Django cache framework homepage, captured Nov 2026

What it is and where it fits

Django ships a cache framework as part of the core package. It provides a low-level cache API, per-view caching, template fragment caching and site-wide caching. Backends include local memory, filesystem, database and Redis via django-redis. Configuration lives in the project settings. Django is BSD licensed.

Because it is part of Django, there is nothing extra to install for the basic backends. The local-memory backend is per-process, so it behaves like cachetools in multi-worker setups. For shared caching you configure a Redis or Memcached backend. This option only makes sense inside a Django project; other frameworks need a different tool.

Standout: Built into Django with no extra package

Pricing pointer

Free (open source), as listed by the vendor (Django cache framework website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Built into Django with no extra package
  • supports memory, file, database and Redis backends

Drawbacks

  • Tied to Django projects
  • backend setup still requires configuration

Skip it if this limit matters to you: tied to Django projects.

Verdict. A sensible pick for caching inside Django web applications.

Alternatives in this guide: cachetools, redis-py, pymemcache

05

Flask-Caching

Best for adding a cache layer to Flask apps

Visit github.com
Flask-Caching homepage
Flask-Caching homepage, captured Nov 2026

What it is and where it fits

Flask-Caching adds caching to Flask applications. You create a Cache instance, configure a backend such as simple, filesystem, Redis or Memcached, and use the cached decorator or the cache API directly. It is maintained under the Pallets-Eco organisation and is BSD licensed.

The extension is free and installs from PyPI. The simple backend keeps data in process memory, which does not share across workers. Redis and Memcached backends need those servers running. Flask-Caching is the natural choice for Flask projects and not useful outside Flask.

Standout: Simple setup through a Cache object

Pricing pointer

Free (open source), as listed by the vendor (Flask-Caching website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Simple setup through a Cache object
  • supports several backends including Redis and Memcached

Drawbacks

  • Flask only
  • backend behaviour and limits depend on the service you choose

Skip it if this limit matters to you: flask only.

Verdict. A sensible pick for adding a cache layer to Flask apps.

Alternatives in this guide: cachetools, redis-py, pymemcache

06

dogpile.cache

Best for caching with locking and expiration policies

Visit github.com
dogpile.cache homepage
dogpile.cache homepage, captured Nov 2026

What it is and where it fits

dogpile.cache is a caching API maintained by the SQLAlchemy project. It organises caches into regions, each with a backend and expiration settings. A key feature is the dogpile lock, which stops many threads from recomputing the same expired value at once. Backends include memory, file, Redis and Memcached. It is MIT licensed.

The library is free and installs from PyPI. It is more involved than cachetools or a framework cache because you define regions and backends explicitly. That control helps in applications with heavy concurrent access to expensive values. Skip it for small scripts where a simple dictionary or cachetools is enough.

Standout: Region-based API with pluggable backends

Pricing pointer

Free (open source), as listed by the vendor (dogpile.cache website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Region-based API with pluggable backends
  • includes a lock to reduce stampedes on expiry

Drawbacks

  • More configuration than simple decorators
  • concepts take time to learn

Skip it if this limit matters to you: more configuration than simple decorators.

Verdict. A sensible pick for caching with locking and expiration policies.

Alternatives in this guide: cachetools, redis-py, pymemcache

07

diskcache

Best for persistent caches stored on local disk

Visit github.com
diskcache homepage
diskcache homepage, captured Nov 2026

What it is and where it fits

diskcache is a disk-backed cache and key-value store for Python. Values persist across process restarts, and you get TTL, tag-based eviction and size limits. It uses SQLite and files under the hood and works on Windows, macOS and Linux. It is Apache 2.0 licensed.

Use diskcache when cached results are expensive to compute and should survive a restart, such as downloaded data or rendered artifacts. It is local to one machine, so it does not replace a shared Redis cache. Reads from disk are slower than memory, so it fits warm data rather than hot request paths.

Standout: Stores cache on disk so it survives restarts

Pricing pointer

Free (open source), as listed by the vendor (diskcache website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Stores cache on disk so it survives restarts
  • supports TTL, tags and eviction policies

Drawbacks

  • Single-machine only
  • slower than memory for hot reads

Skip it if this limit matters to you: single-machine only.

Verdict. A sensible pick for persistent caches stored on local disk.

Alternatives in this guide: cachetools, redis-py, pymemcache

08

aiocache

Best for async caching in asyncio applications

Visit github.com
aiocache homepage
aiocache homepage, captured Nov 2026

What it is and where it fits

aiocache provides an async cache API for asyncio code. It offers memory, Redis and Memcached backends, decorators such as cached, and pluggable serializers. It is maintained by the aio-libs organisation and is BSD licensed.

The library is free and installs from PyPI. It fits async web frameworks and services where blocking a cache call would stall the event loop. The memory backend is per-process, so shared caching needs Redis or Memcached. Skip it in synchronous code, where cachetools or a framework cache is simpler.

Standout: Async API with memory, Redis and Memcached backends

Pricing pointer

Free (open source), as listed by the vendor (aiocache website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Async API with memory, Redis and Memcached backends
  • includes decorators and serializers

Drawbacks

  • asyncio only
  • backend setup still needed for shared caches

Skip it if this limit matters to you: asyncio only.

Verdict. A sensible pick for async caching in asyncio applications.

Alternatives in this guide: cachetools, redis-py, pymemcache

Who should use what

For a script or single-process service, use cachetools. For a Django or Flask app, start with the framework's own cache and add Redis only when you need sharing. For caches shared across workers or machines, use redis-py or pymemcache with a server you run. For async services, pick aiocache. For results that must survive restarts on one machine, use diskcache, and for concurrent recomputation, dogpile.cache.

Questions to settle before you buy

What to check before you buy

  • Confirm whether the cache must be shared across processes or machines, which rules out in-memory-only options.
  • Check the licence and whether the client is free while the server has separate costs.
  • Set a memory limit and eviction policy on Redis or Memcached so keys do not grow without bound.
  • Decide whether cached data must survive a restart, which points to diskcache or a persistent server.
  • Test invalidation and expiry behaviour under your real concurrency before relying on it.

FAQ

Do I need Redis to cache in Python?

No. cachetools, Django's local-memory backend, Flask-Caching's simple backend and diskcache all cache without Redis. You only need Redis or Memcached when several processes or machines must share the same cache.

Are these caching libraries free?

Yes. Every library listed here is free and open source under licences such as MIT, BSD or Apache 2.0. The Redis and Memcached servers may cost money if you use a managed service, but the Python clients do not.

Which library works with asyncio?

aiocache is built for asyncio and offers an async API with memory, Redis and Memcached backends. redis-py also supports asyncio. Synchronous libraries like cachetools block the event loop, so avoid them in async request paths.

What is the difference between cachetools and diskcache?

cachetools keeps data in process memory, so it is fast but lost on restart and not shared. diskcache stores data on local disk using SQLite, so it survives restarts but is slower and limited to one machine.

How do I stop many threads recomputing an expired value?

dogpile.cache includes a lock that lets one thread recompute an expired value while others wait or use the stale value. This reduces stampedes on expensive calls compared with a plain decorator cache.

Sources we checked

Method: how we score · editorial policy.

  1. cachetools (official site)
  2. redis-py (official site)
  3. pymemcache (official site)
  4. Django cache framework (official site)
  5. Flask-Caching (official site)
  6. dogpile.cache (official site)
  7. diskcache (official site)
  8. aiocache (official site)

Change log. First published 27 Nov 2026.