diff --git a/example/settings.py b/example/settings.py index ffaa09fe5..ad24978ba 100644 --- a/example/settings.py +++ b/example/settings.py @@ -73,7 +73,7 @@ # Cache and database -CACHES = {"default": {"BACKEND": "django.core.cache.backends.dummy.DummyCache"}} +CACHES = {"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}} DATABASES = { "default": { diff --git a/example/templates/cache.html b/example/templates/cache.html new file mode 100644 index 000000000..d95a664bb --- /dev/null +++ b/example/templates/cache.html @@ -0,0 +1,11 @@ + + + + + Cache + + +

Cache Test

+

Check the cache panel to see the cache hits and misses.

+ + diff --git a/example/templates/index.html b/example/templates/index.html index a10c2b5ac..021dc55b7 100644 --- a/example/templates/index.html +++ b/example/templates/index.html @@ -15,6 +15,7 @@

Index of Tests

  • Prototype 1.7.3.0
  • Hotwire Turbo
  • htmx
  • +
  • Cache
  • Bad form
  • Django Admin

    diff --git a/example/urls.py b/example/urls.py index 86e6827fc..b482896b1 100644 --- a/example/urls.py +++ b/example/urls.py @@ -7,6 +7,7 @@ async_db, async_db_concurrent, async_home, + cache_view, increment, jinja2_view, ) @@ -47,6 +48,7 @@ ), name="turbo2", ), + path("cache/", cache_view, name="cache"), path("admin/", admin.site.urls), path("ajax/increment", increment, name="ajax_increment"), ] + debug_toolbar_urls() diff --git a/example/views.py b/example/views.py index 3e1cb04a6..b87b02661 100644 --- a/example/views.py +++ b/example/views.py @@ -2,6 +2,7 @@ from asgiref.sync import sync_to_async from django.contrib.auth.models import User +from django.core.cache import cache from django.http import JsonResponse from django.shortcuts import render @@ -40,3 +41,10 @@ async def async_db_concurrent(request): return await sync_to_async(render)( request, "async_db.html", {"user_count": user_count} ) + + +def cache_view(request): + cache.set("foo", "bar") + cache.get("foo") + cache.get("baz") + return render(request, "cache.html")