Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
11 changes: 11 additions & 0 deletions example/templates/cache.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Cache</title>
</head>
<body>
<h1>Cache Test</h1>
<p>Check the cache panel to see the cache hits and misses.</p>
</body>
</html>
1 change: 1 addition & 0 deletions example/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ <h1>Index of Tests</h1>
<li><a href="/prototype/">Prototype 1.7.3.0</a></li>
<li><a href="{% url 'turbo' %}">Hotwire Turbo</a></li>
<li><a href="{% url 'htmx' %}">htmx</a></li>
<li><a href="{% url 'cache' %}">Cache</a></li>
<li><a href="{% url 'bad_form' %}">Bad form</a></li>
</ul>
<p><a href="/admin/">Django Admin</a></p>
Expand Down
2 changes: 2 additions & 0 deletions example/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
async_db,
async_db_concurrent,
async_home,
cache_view,
increment,
jinja2_view,
)
Expand Down Expand Up @@ -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()
8 changes: 8 additions & 0 deletions example/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")