From 8d18692809593c2c416d5c619719b141e3d9bbe2 Mon Sep 17 00:00:00 2001 From: nineven Date: Sat, 11 Apr 2020 15:23:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Drelease=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E7=BC=93=E5=AD=98bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_ser/api/utils/serializer.py | 2 +- fir_ser/api/utils/storage/caches.py | 5 ++++- fir_ser/api/views/download.py | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fir_ser/api/utils/serializer.py b/fir_ser/api/utils/serializer.py index 099bfd7..23880f1 100644 --- a/fir_ser/api/utils/serializer.py +++ b/fir_ser/api/utils/serializer.py @@ -82,7 +82,7 @@ class AppsSerializer(serializers.ModelSerializer): class AppsShortSerializer(serializers.ModelSerializer): class Meta: model = models.Apps - fields = ["app_id","name","short","has_combo","isshow","description","need_password",'master_release'] + fields = ["app_id","name","short","has_combo","isshow","description","need_password",'master_release','type'] need_password=serializers.SerializerMethodField() diff --git a/fir_ser/api/utils/storage/caches.py b/fir_ser/api/utils/storage/caches.py index cfc05b9..2816a91 100644 --- a/fir_ser/api/utils/storage/caches.py +++ b/fir_ser/api/utils/storage/caches.py @@ -62,8 +62,11 @@ def set_app_download_by_cache(app_id, limit=900): def del_cache_response_by_short(short,app_id): cache.delete("_".join([CACHE_KEY_TEMPLATE.get("download_short_key"),short])) - cache.delete("_".join([CACHE_KEY_TEMPLATE.get("app_instance_key"),app_id])) + key = "_".join([CACHE_KEY_TEMPLATE.get("download_short_key"),short,'*']) + for app_download_key in cache.iter_keys(key): + cache.delete(app_download_key) + cache.delete("_".join([CACHE_KEY_TEMPLATE.get("app_instance_key"),app_id])) key='ShortDownloadView'.lower() master_release_dict = AppReleaseInfo.objects.filter(app_id__app_id=app_id,is_master=True).values('icon_url','release_id').first() diff --git a/fir_ser/api/views/download.py b/fir_ser/api/views/download.py index 59aa354..4257fa2 100644 --- a/fir_ser/api/views/download.py +++ b/fir_ser/api/views/download.py @@ -93,7 +93,8 @@ class ShortDownloadView(APIView): #key的设置 def calculate_cache_key(self, view_instance, view_method, request, args, kwargs): - return "_".join([settings.CACHE_KEY_TEMPLATE.get("download_short_key"), kwargs.get("short", None)]) + release_id = request.query_params.get("release_id", '') + return "_".join([settings.CACHE_KEY_TEMPLATE.get("download_short_key"), kwargs.get("short", ''),release_id]) class InstallView(APIView): '''