jumpserver/apps/common/management/commands/expire_caches.py

29 lines
845 B
Python
Raw Normal View History

2021-04-27 06:21:48 +00:00
from django.core.management.base import BaseCommand
from assets.signal_handlers.node_assets_mapping import expire_node_assets_mapping_for_memory
2021-08-19 07:40:41 +00:00
from orgs.caches import OrgResourceStatisticsCache
2021-04-27 06:21:48 +00:00
from orgs.models import Organization
def expire_node_assets_mapping():
org_ids = Organization.objects.all().values_list('id', flat=True)
org_ids = [*org_ids, '00000000-0000-0000-0000-000000000000']
for org_id in org_ids:
expire_node_assets_mapping_for_memory(org_id)
2021-08-19 07:40:41 +00:00
def expire_org_resource_statistics_cache():
orgs = Organization.objects.all()
for org in orgs:
cache = OrgResourceStatisticsCache(org)
cache.expire()
2021-04-27 06:21:48 +00:00
class Command(BaseCommand):
help = 'Expire caches'
def handle(self, *args, **options):
expire_node_assets_mapping()
2021-08-19 07:40:41 +00:00
expire_org_resource_statistics_cache()