# -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand


class Command(BaseCommand):
    help = """Инвалидирует кэш"""

    def handle(self, *args, **options):
        # todo: test me
        from events.rest_framework_contrib.utils import get_validation_mixture_key
        from events.rest_framework_contrib.signal_handlers import invalidate_api
        from django.core.cache import cache

        key = get_validation_mixture_key(api_name='/v1/')
        invalidate_from = cache.get(key)
        invalidate_api()
        invalidate_to = cache.get(key)

        print('invalidated from "%(from)s" to "%(to)s"' % {'from': invalidate_from, 'to': invalidate_to})
