This commit is contained in:
wea_ondara
2019-12-28 13:30:25 +01:00
parent e54e4f2938
commit 221953f3b9
2 changed files with 64 additions and 0 deletions

View File

@@ -26,7 +26,20 @@ def dmp(data, progressinterval=5000): return mt(multiprocessing.cpu_count(), dat
def cms(): return int(round(time.time() * 1000))
class Cache:
CACHED_FOLDER = None
CACHED_USERS = None
CACHED_POSTS = None
CACHED_FIRSTCONTRIB = None
CACHED_SUMCONTRIB = None
def load(folder):
if folder == Cache.CACHED_FOLDER:
return Cache.CACHED_USERS, Cache.CACHED_POSTS, Cache.CACHED_FIRSTCONTRIB, Cache.CACHED_SUMCONTRIB
Cache.CACHED_FOLDER = None
users = readUsers(folder + "/Users.xml")
gc.collect()
posts = readPosts(folder + "/Posts.xml")
@@ -36,6 +49,12 @@ def load(folder):
firstcontrib = computefirstcontrib(posts)
sumcontrib = computesumcontrib(posts)
Cache.CACHED_USERS = users
Cache.CACHED_POSTS = posts
Cache.CACHED_FIRSTCONTRIB = firstcontrib
Cache.CACHED_SUMCONTRIB = sumcontrib
Cache.CACHED_FOLDER = folder
return users, posts, firstcontrib, sumcontrib