修复APP删除之后,缓存未清理

pull/6/head
nineven 4 years ago
parent f2d8619083
commit b02563a377
  1. 17
      fir_ser/api/utils/storage/caches.py
  2. 4
      fir_ser/api/views/apps.py

@ -139,10 +139,6 @@ def del_cache_response_by_short(app_id, udid=''):
def del_cache_response_by_short_util(short, app_id, udid):
logger.info("del_cache_response_by_short short:%s app_id:%s udid:%s" % (short, app_id, udid))
cache.delete("_".join([CACHE_KEY_TEMPLATE.get("download_short_key"), short]))
now = timezone.now()
down_tem_key = "_".join([CACHE_KEY_TEMPLATE.get("download_today_times_key"),
str(now.year), str(now.month), str(now.day), app_id])
cache.delete(down_tem_key)
key = "_".join([CACHE_KEY_TEMPLATE.get("download_short_key"), short, '*'])
for app_download_key in cache.iter_keys(key):
cache.delete(app_download_key)
@ -160,6 +156,19 @@ def del_cache_response_by_short_util(short, app_id, udid):
"_".join([key, CACHE_KEY_TEMPLATE.get("make_token_key"), master_release_dict.get('release_id'), udid]))
def del_cache_by_delete_app(app_id):
now = timezone.now()
down_tem_key = "_".join([CACHE_KEY_TEMPLATE.get("download_today_times_key"),
str(now.year), str(now.month), str(now.day), app_id])
cache.delete(down_tem_key)
down_tem_key = "_".join([CACHE_KEY_TEMPLATE.get("download_times_key"), app_id])
download_times = cache.get(down_tem_key)
cache.delete(download_times)
cache.delete("_".join([CACHE_KEY_TEMPLATE.get("app_instance_key"), app_id]))
def del_cache_by_app_id(app_id, user_obj):
key = ''
master_release_dict = AppReleaseInfo.objects.filter(app_id__app_id=app_id, is_master=True).values('icon_url',

@ -11,7 +11,7 @@ from rest_framework.response import Response
from django.db.models import Sum
from api.utils.app.supersignutils import IosUtils
from api.utils.storage.storage import Storage
from api.utils.storage.caches import del_cache_response_by_short, get_app_today_download_times
from api.utils.storage.caches import del_cache_response_by_short, get_app_today_download_times, del_cache_by_delete_app
from api.models import Apps, AppReleaseInfo, APPToDeveloper, AppIOSDeveloperInfo, UserInfo
from api.utils.serializer import AppsSerializer, AppReleaseSerializer, UserInfoSerializer
from rest_framework.pagination import PageNumberPagination
@ -132,6 +132,7 @@ class AppInfoView(APIView):
app_id))
apps_obj.has_combo.has_combo = None
del_cache_response_by_short(apps_obj.app_id)
del_cache_by_delete_app(apps_obj.app_id)
for appreleaseobj in AppReleaseInfo.objects.filter(app_id=apps_obj).all():
logger.info("delete app_id:%s need clean all release,release_id:%s" % (
app_id, appreleaseobj.release_id))
@ -302,6 +303,7 @@ class AppReleaseinfoView(APIView):
storage.delete_file(appreleaseobj.release_id, appreleaseobj.release_type)
storage.delete_file(appreleaseobj.icon_url)
del_cache_by_delete_app(apps_obj.app_id)
appreleaseobj.delete()

Loading…
Cancel
Save