[Update] 用户资产添加缓存

This commit is contained in:
ibuler
2019-03-04 20:45:57 +08:00
parent dcf6959cff
commit dfd26d88d4
10 changed files with 785 additions and 668 deletions

View File

@@ -310,7 +310,8 @@ class User(AbstractUser):
if not isinstance(remote_addr, bytes):
remote_addr = remote_addr.encode("utf-8")
remote_addr = base64.b16encode(remote_addr) # .replace(b'=', '')
token = cache.get('%s_%s' % (self.id, remote_addr))
cache_key = '%s_%s' % (self.id, remote_addr)
token = cache.get(cache_key)
if not token:
token = uuid.uuid4().hex
cache.set(token, self.id, expiration)