This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
from django.core.management.base import BaseCommand
from djangoblog.utils import cache
class Command(BaseCommand):
"""
mk:
Django管理命令类,用于清除整个缓存
该类继承自Django的BaseCommand,提供了一个自定义的管理命令
可以通过命令行调用来清除应用的所有缓存数据
help = 'clear the whole cache'
def handle(self, *args, **options):
处理管理命令的主要逻辑
参数:
*args: 位置参数元组
**options: 关键字参数字典
返回值:
None
# mk:清除所有缓存数据
cache.clear()
# mk:输出成功信息到标准输出
self.stdout.write(self.style.SUCCESS('Cleared cache\n'))