优化代码

dependabot/npm_and_yarn/fir_admin/tmpl-1.0.5
youngS 3 years ago
parent 4316398d82
commit b815950f7d
  1. 4
      fir_ser/api/utils/storage/aliyunApi.py
  2. 11
      fir_ser/api/utils/storage/caches.py

@ -118,8 +118,8 @@ class AliYunOss(object):
def fetch_sts_token(self, name, expires, only_put=False, only_get=False):
"""子用户角色扮演获取临时用户的密钥
:param only_put: 是否只允许下载
:param only_get: 是否只允许上传
:param only_put: 是否只允许上传
:param only_get: 是否只允许下载
:param expires: 过期时间
:param name: obj name
:return StsToken: 临时用户密钥

@ -480,8 +480,10 @@ def get_wx_ticket_login_info_cache(ticket):
cache.delete(wx_t_key)
return wx_ticket_info
class CacheBaseState(object):
prefix=''
prefix = ''
def __init__(self, prefix):
CacheBaseState.prefix = prefix
@ -490,14 +492,15 @@ class CacheBaseState(object):
return cache.get(f"{cls.prefix}_{key}")
@classmethod
def set_state(cls, key,value= time.time(),timeout=3600*24):
def set_state(cls, key, value=time.time(), timeout=3600 * 24):
cls.del_state(f"{cls.prefix}_{key}")
cache.set(f"{cls.prefix}_{key}",value,timeout)
cache.set(f"{cls.prefix}_{key}", value, timeout)
@classmethod
def del_state(cls,key):
def del_state(cls, key):
cache.delete(f"{cls.prefix}_{key}")
class MigrateStorageState(CacheBaseState):
def __init__(self):
super().__init__('migrate_storage')

Loading…
Cancel
Save