Skip to content

Commit abfab01

Browse files
vintacodex
andcommitted
docs: restore dogpile.cache in general caching
Replacing framework-independent dogpile.cache with Django-only django-redis removed the shared Redis and Memcached cache use case, and a single Caching group conflated distinct jobs. Co-Authored-By: Codex <noreply@openai.com>
1 parent 32ac8c9 commit abfab01

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎README.md‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,15 @@ _In-process databases usable directly from Python._
484484

485485
_Libraries for caching data._
486486

487-
- [cachetools](https://github.com/tkem/cachetools) - Extensible memoizing collections and decorators.
488-
- [diskcache](https://github.com/grantjenks/python-diskcache) - SQLite and file backed cache backend, compatible with Django.
489-
- [django-redis](https://github.com/jazzband/django-redis) - Full-featured Redis cache backend for Django.
490-
- [hishel](https://github.com/karpetrosyan/hishel) - RFC 9111 compliant HTTP caching for clients like httpx and requests and servers like FastAPI, with sync and async support.
491-
- [django-cacheops](https://github.com/Suor/django-cacheops) - A slick ORM cache with automatic granular event-driven invalidation.
487+
- General
488+
- [cachetools](https://github.com/tkem/cachetools) - Extensible memoizing collections and decorators.
489+
- [diskcache](https://github.com/grantjenks/python-diskcache) - SQLite and file backed cache backend, compatible with Django.
490+
- [dogpile.cache](https://github.com/sqlalchemy/dogpile.cache) - A caching API for Redis, Memcached, and other backends, with coordinated value regeneration.
491+
- HTTP Responses
492+
- [hishel](https://github.com/karpetrosyan/hishel) - RFC 9111 compliant HTTP caching for clients like httpx and requests and servers like FastAPI, with sync and async support.
493+
- Django
494+
- [django-redis](https://github.com/jazzband/django-redis) - Full-featured Redis cache backend for Django.
495+
- [django-cacheops](https://github.com/Suor/django-cacheops) - A slick ORM cache with automatic granular event-driven invalidation.
492496

493497
### Search
494498

‎website/data/category_intros/caching.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ How to choose:
55
- Memoizing a function in one process, with a size limit or an expiry time: cachetools
66
- A persistent cache on local disk that several processes share: DiskCache
77
- A Django cache backend on local disk: DiskCache
8+
- A shared Redis or Memcached cache outside Django, with coordinated value regeneration: dogpile.cache
89
- A Django cache and session store on Redis: django-redis
910
- Caching HTTP responses in HTTPX or Requests, or setting cache headers in FastAPI: Hishel
1011
- Django ORM queries cached in Redis and invalidated when the data changes: Cacheops
@@ -13,6 +14,8 @@ cachetools offers [variants of the standard library's `@lru_cache` decorator](ht
1314

1415
DiskCache keeps keys and values in [a SQLite database and a directory of files](https://grantjenks.com/docs/diskcache/), with no server process to run. Point a `Cache` at a directory, and [other threads and processes that open the same directory](https://grantjenks.com/docs/diskcache/tutorial.html#tutorial-cache) share its entries. Its `memoize()` decorator takes [arguments like `lru_cache`'s](https://grantjenks.com/docs/diskcache/tutorial.html#tutorial-fanoutcache), plus an expiry time. In Django, [set `diskcache.DjangoCache` as the `BACKEND`](https://grantjenks.com/docs/diskcache/tutorial.html#tutorial-djangocache) and a directory as the `LOCATION`.
1516

17+
dogpile.cache gives you [one caching API over Redis, Memcached, and other backends](https://dogpilecache.sqlalchemy.org/en/latest/usage.html), without depending on a web framework. Create a region with `make_region()`, configure its backend, and call `get_or_create()` with a key and a function that computes the value. For shared Redis or Memcached caches, enable [`distributed_lock`](https://dogpilecache.sqlalchemy.org/en/latest/api.html) so one worker regenerates an expired value while others use the previous one.
18+
1619
django-redis is a [full-featured Redis cache and session backend](https://github.com/jazzband/django-redis#introduction) for Django. [Set `django_redis.cache.RedisCache` as the `BACKEND`](https://github.com/jazzband/django-redis#configure-as-cache-backend) and a redis-py URL like `redis://127.0.0.1:6379/1` as the `LOCATION`. Sessions then need no extra backend: [point `SESSION_ENGINE` at Django's cache sessions](https://github.com/jazzband/django-redis#configure-as-session-backend), and they live in Redis too. Its clients, parsers, and serializers [are pluggable](https://github.com/jazzband/django-redis#why-use-django-redis).
1720

1821
Hishel caches HTTP responses [by RFC 9111](https://hishel.com/overview.html), the rules browsers follow. It works in sync and async code, and comes with a backend that stores responses in SQLite. In HTTPX, [use `SyncCacheClient` or `AsyncCacheClient`](https://hishel.com/httpx.html#cache-clients), drop-in replacements for `Client` and `AsyncClient`. In Requests, [mount its `CacheAdapter`](https://hishel.com/requests.html#quick-start) on a `Session`. In FastAPI, [the `cache()` dependency](https://hishel.com/fastapi.html) sends Cache-Control headers to browsers and CDNs, and Hishel's ASGI middleware adds a cache on your server.

0 commit comments

Comments
 (0)