Use FormCache

This commit is contained in:
richard-dds
2018-11-16 11:38:58 -05:00
parent cd4a5df2d6
commit 6177f46587
2 changed files with 3 additions and 3 deletions

View File

@@ -32,10 +32,11 @@ class FormCache(object):
value = pickle.dumps(formdata)
hash_ = hashlib.sha1(os.urandom(64)).hexdigest()
self.redis.setex(name=self._key(key_prefix, hash_), value=value, time=expiry_seconds)
return hash_
def read(self, formdata_key, key_prefix="formcache"):
data = self.redis.get(self._key(key_prefix, formdata_key))
return pickle.loads(data)
return pickle.loads(data) if data is not None else {}
@staticmethod
def _key(prefix, hash_):