Add management command to clear diagram cache
Usage: python manage.py clear_diagram_cache python manage.py clear_diagram_cache --type plantuml
This commit is contained in:
23
abschnitte/management/commands/clear_diagram_cache.py
Normal file
23
abschnitte/management/commands/clear_diagram_cache.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
from diagramm_proxy.diagram_cache import clear_cache
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = 'Clear cached diagrams'
|
||||||
|
|
||||||
|
def add_arguments(self, parser):
|
||||||
|
parser.add_argument(
|
||||||
|
'--type',
|
||||||
|
type=str,
|
||||||
|
help='Diagram type to clear (e.g., plantuml, mermaid)',
|
||||||
|
)
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
diagram_type = options.get('type')
|
||||||
|
if diagram_type:
|
||||||
|
self.stdout.write(f'Clearing cache for {diagram_type}...')
|
||||||
|
clear_cache(diagram_type)
|
||||||
|
else:
|
||||||
|
self.stdout.write('Clearing all diagram caches...')
|
||||||
|
clear_cache()
|
||||||
|
self.stdout.write(self.style.SUCCESS('Cache cleared successfully'))
|
||||||
Reference in New Issue
Block a user