From 9b1329dc7ceab18ea46f77dbd1aff36fba1bc3a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Sch=C3=A4fer?= <felix@thegcat.net>
Date: Mon, 6 Feb 2023 20:49:33 +0100
Subject: [PATCH] Use more compact cache method

---
 pretix_public_registrations/signals.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/pretix_public_registrations/signals.py b/pretix_public_registrations/signals.py
index aec746f..a6184ab 100644
--- a/pretix_public_registrations/signals.py
+++ b/pretix_public_registrations/signals.py
@@ -26,11 +26,10 @@ def add_public_registrations_html_head(sender, request=None, **kwargs):
     url = resolve(request.path_info)
     if "event.index" not in url.url_name:
         return ""
-    cached = sender.cache.get("public_registrations_html_head")
-    if cached is None:
-        cached = get_template("pretix_public_registrations/head.html").render()
-    sender.cache.set("public_registrations_html_head", cached)
-    return cached
+    return sender.cache.get_or_set(
+        "public_registrations_html_head",
+        get_template("pretix_public_registrations/head.html").render(),
+    )
 
 
 @receiver(question_form_fields, dispatch_uid="public_registration_question")
-- 
GitLab