修复release版本下载缓存bug

super_signature
nineven 5 years ago
parent 47f2f534c7
commit 8d18692809
  1. 2
      fir_ser/api/utils/serializer.py
  2. 5
      fir_ser/api/utils/storage/caches.py
  3. 3
      fir_ser/api/views/download.py

@ -82,7 +82,7 @@ class AppsSerializer(serializers.ModelSerializer):
class AppsShortSerializer(serializers.ModelSerializer): class AppsShortSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = models.Apps 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() need_password=serializers.SerializerMethodField()

@ -62,8 +62,11 @@ def set_app_download_by_cache(app_id, limit=900):
def del_cache_response_by_short(short,app_id): 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("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() key='ShortDownloadView'.lower()
master_release_dict = AppReleaseInfo.objects.filter(app_id__app_id=app_id,is_master=True).values('icon_url','release_id').first() master_release_dict = AppReleaseInfo.objects.filter(app_id__app_id=app_id,is_master=True).values('icon_url','release_id').first()

@ -93,7 +93,8 @@ class ShortDownloadView(APIView):
#key的设置 #key的设置
def calculate_cache_key(self, view_instance, view_method, def calculate_cache_key(self, view_instance, view_method,
request, args, kwargs): 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): class InstallView(APIView):
''' '''

Loading…
Cancel
Save