Explorar o código

调用联通API,优化token缓存

zhangdongming %!s(int64=2) %!d(string=hai) anos
pai
achega
979027baec
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      Object/UnicomObject.py

+ 2 - 1
Object/UnicomObject.py

@@ -117,7 +117,8 @@ class UnicomObjeect:
         response_data = json.loads(response_data.text)
         token = response_data['access_token']
         expires_in = response_data['expires_in']
-        redis.set_data(UNICOM_KEY, token, int(expires_in))
+        redis.CONN.setnx(UNICOM_KEY, token)
+        redis.CONN.expire(UNICOM_KEY, int(expires_in))
         return token
 
     def refresh_token(self, refresh_token):