--- id: django-cacheops version: "7.2" license: BSD license_treatment: permissive maintenance: active --- # django-cacheops — A slick ORM cache with automatic granular event-driven invalidation for Django. License: permissive · Maintenance: active · Downloads: 1.3M/mo ## What it is and what it does django-cacheops is a Django caching layer that sits between your ORM and Redis to automatically cache querysets and invalidate them when underlying data changes. It supports both automatic caching (configured per-model) and manual caching via `.cache()` method calls, plus decorators for caching function results. The package uses Redis as its primary backend and can fall back to filesystem-based time-invalidated caching for simpler use cases. The core value is granular, event-driven invalidation: when you save, delete, or update a model instance, cacheops automatically invalidates only the relevant cached queries rather than flushing everything. It also provides decorators to cache any user function or view, template extensions for Django and Jinja2, transparent transaction support, and a dog-pile prevention mechanism to avoid thundering-herd problems when cache entries expire. Use it for: - Cache frequently accessed User.objects.get() calls across a Django app to reduce database load on auth queries. - Automatically invalidate cached article listings when posts are published, updated, or deleted without manual cache management. - Decorate expensive reporting functions with @cached_as(Model) to cache results and invalidate them on model changes. - Use .nocache() to disable automatic caching on specific querysets when you need fresh data in particular code paths. - Cache count and aggregate operations on large tables separately from fetch operations to optimize pagination. - Configure per-model cache timeouts and operations (get, fetch, count, aggregate, exists) to fine-tune what gets cached. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Automatic and manual ORM query caching for Django with Redis-backed storage and granular event-driven cache invalidation tied to model changes. Yes. django-cacheops is actively maintained, has no known vulnerabilities, low install friction, and solves a real Django performance problem with a mature API. The permissive BSD license and broad Python/Django version support (3.8+ and Django 3.2–5.2) make it a safe choice. Install it if you have a Django app with database-heavy ORM queries and a Redis instance available; the automatic invalidation model eliminates much of the complexity of manual cache management. ## Install pip install django-cacheops uv add django-cacheops poetry add django-cacheops ## Installing django-cacheops Before you install: Low install friction; wheel distribution available. Actively maintained with recent commits and stable production status. Requires Redis 4.0+ as a runtime dependency alongside Django 3.2+ and Python 3.8+. License in practice: BSD permissive license allows commercial and private use with minimal restrictions; suitable for most projects. Quickstart: pip install django-cacheops # In Django settings.py: INSTALLED_APPS = ['cacheops', ...] CACHEOPS_REDIS = 'redis://localhost:6379/1' CACHEOPS = {'auth.user': {'ops': 'get', 'timeout': 60*15}} # In code: from cacheops import cached_as user = User.objects.get(id=1) # cached automatically result = Article.objects.filter(tag=2).cache() Redis 4.0+ server must be running and accessible; Django 3.2+ and Python 3.8+ required. Verify before relying: - Whether dog-pile prevention mechanism and transaction support work as documented in production scenarios. - Performance impact of signal binding overhead on models with high write volume. - Compatibility with Django ORM features introduced after version 5.2. ## Package facts - License: BSD (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 1.3M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags django orm caching, redis query cache, automatic cache invalidation, django queryset cache, cache decorator django, orm cache invalidation, django performance optimization, django-orm, redis-cache, query-optimization [View on SkillFed](https://skillfed.io/packages/django-cacheops) · [View on PyPI](https://pypi.org/project/django-cacheops/)