MaxKB/apps/common/cache_data/application_access_token_ca...

31 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# coding=utf-8
"""
@project: MaxKB
@Author
@file application_access_token_cache.py
@date2024/7/25 11:34
@desc:
"""
from django.core.cache import cache
from django.db.models import QuerySet
from application.models import ApplicationAccessToken
from common.utils.cache_util import get_cache
@get_cache(cache_key=lambda access_token, use_get_data: access_token,
use_get_data=lambda access_token, use_get_data: use_get_data,
version='APPLICATION_ACCESS_TOKEN_CACHE')
def get_application_access_token(access_token, use_get_data):
application_access_token = QuerySet(ApplicationAccessToken).filter(access_token=access_token).first()
if application_access_token is None:
return None
return {'white_active': application_access_token.white_active,
'white_list': application_access_token.white_list,
'application_icon': application_access_token.application.icon,
'application_name': application_access_token.application.name}
def del_application_access_token(access_token):
cache.delete(access_token, version='APPLICATION_ACCESS_TOKEN_CACHE')