forked from ScoDoc/ScoDoc
Performance boost: NotesTableCache was not always caching locally
This commit is contained in:
parent
3ac4623421
commit
2fbce89edd
@ -225,15 +225,18 @@ class NotesTableCache(ScoDocCache):
|
||||
# try REDIS
|
||||
key = cls._get_key(formsemestre_id)
|
||||
nt = CACHE.get(key)
|
||||
if nt or not compute:
|
||||
if nt:
|
||||
g.nt_cache[formsemestre_id] = nt # cache locally (same request)
|
||||
return nt
|
||||
# Recompute asked table:
|
||||
if not compute:
|
||||
return None
|
||||
# Recompute requested table:
|
||||
from app.scodoc import notes_table
|
||||
|
||||
t0 = time.time()
|
||||
nt = notes_table.NotesTable(formsemestre_id)
|
||||
t1 = time.time()
|
||||
_ = cls.set(formsemestre_id, nt)
|
||||
_ = cls.set(formsemestre_id, nt) # cache in REDIS
|
||||
t2 = time.time()
|
||||
log(f"cached formsemestre_id={formsemestre_id} ({(t1-t0):g}s +{(t2-t1):g}s)")
|
||||
g.nt_cache[formsemestre_id] = nt
|
||||
|
Loading…
Reference in New Issue
Block a user