소스 검색

v2 redis释放资源

zhangdongming 1 년 전
부모
커밋
0e55f059d1
1개의 변경된 파일3개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 2
      Controller/DetectControllerV2.py

+ 3 - 2
Controller/DetectControllerV2.py

@@ -58,7 +58,7 @@ class NotificationV2View(View):
         is_st = int(is_st)
         region = int(region)
         event_type = int(event_type)
-
+        redis_obj = RedisObject()
         try:
             uid = DevicePushService.decode_uid(etk, uidToken)
             if len(uid) != 20 and len(uid) != 14:
@@ -72,7 +72,6 @@ class NotificationV2View(View):
             else:
                 push_interval = '{uid}_{channel}_flag'.format(uid=uid, channel=channel)
 
-            redis_obj = RedisObject()
             req_limiting = '{uid}_{channel}_{event_type}_ptl'.format(uid=uid, channel=channel, event_type=event_type)
             cache_req_limiting = redis_obj.get_data(key=req_limiting)  # 获取请求限流缓存数据
             cache_app_push = redis_obj.get_data(key=push_interval)  # 获取APP推送消息时间间隔缓存数据
@@ -143,3 +142,5 @@ class NotificationV2View(View):
                 'errMsg': repr(e),
             }
             return JsonResponse(status=200, data=json.dumps(data), safe=False)
+        finally:
+            redis_obj.CONN.close()