Selaa lähdekoodia

Fixes: #18021 - Clear Swagger/drf-spectacular API cache on startup (#18174)

* Clear Swagger API cache on startup

* Clear entire Redis cache on startup if DEBUG=True
bctiemann 1 vuosi sitten
vanhempi
commit
dbaa9c1ce1
1 muutettua tiedostoa jossa 6 lisäystä ja 0 poistoa
  1. 6 0
      netbox/core/apps.py

+ 6 - 0
netbox/core/apps.py

@@ -1,4 +1,6 @@
 from django.apps import AppConfig
 from django.apps import AppConfig
+from django.conf import settings
+from django.core.cache import cache
 from django.db import models
 from django.db import models
 from django.db.migrations.operations import AlterModelOptions
 from django.db.migrations.operations import AlterModelOptions
 
 
@@ -22,3 +24,7 @@ class CoreConfig(AppConfig):
 
 
         # Register models
         # Register models
         register_models(*self.get_models())
         register_models(*self.get_models())
+
+        # Clear Redis cache on startup in development mode
+        if settings.DEBUG:
+            cache.clear()