|
@@ -106,6 +106,9 @@ def init_vaild_cache():
|
|
#保存验证的参数,有请求时延迟5分钟触发保存
|
|
#保存验证的参数,有请求时延迟5分钟触发保存
|
|
def save_vaild_cache():
|
|
def save_vaild_cache():
|
|
time.sleep(10) #5分钟
|
|
time.sleep(10) #5分钟
|
|
|
|
+ global need_save
|
|
|
|
+ if need_save == False:
|
|
|
|
+ return
|
|
# time.sleep(5*60) #5分钟
|
|
# time.sleep(5*60) #5分钟
|
|
if vaild_cache is not None:
|
|
if vaild_cache is not None:
|
|
#保存数据到数据库
|
|
#保存数据到数据库
|
|
@@ -125,7 +128,7 @@ def save_vaild_cache():
|
|
db.add(new_dict)
|
|
db.add(new_dict)
|
|
db.commit()
|
|
db.commit()
|
|
vaild_cache['id'] = new_dict.id
|
|
vaild_cache['id'] = new_dict.id
|
|
- global need_save
|
|
|
|
|
|
+
|
|
need_save = False
|
|
need_save = False
|
|
|
|
|
|
#重置验证参数
|
|
#重置验证参数
|
|
@@ -134,6 +137,7 @@ def reset_vaild_cache():
|
|
if vaild_cache != {} and 'id' in vaild_cache:
|
|
if vaild_cache != {} and 'id' in vaild_cache:
|
|
db = next(get_db())
|
|
db = next(get_db())
|
|
db.delete( db.query(DictSystem).filter_by(id=vaild_cache['id']).first()) #删除信息
|
|
db.delete( db.query(DictSystem).filter_by(id=vaild_cache['id']).first()) #删除信息
|
|
|
|
+ db.commit()
|
|
vaild_cache={}
|
|
vaild_cache={}
|
|
global need_save
|
|
global need_save
|
|
need_save = False
|
|
need_save = False
|