mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Small refactor
This commit is contained in:
parent
bde06deb4f
commit
0f473599a7
@ -19,10 +19,13 @@ hits, misses = 0, 0
|
||||
|
||||
|
||||
@runhourly
|
||||
def print_stats():
|
||||
log(f"Cache Size: {len(cache)}, RAM Utilization: {psutil.virtual_memory().percent}%, Cache Hits: {hits}/{hits+misses}")
|
||||
def maintenance():
|
||||
print_stats()
|
||||
trim_cache()
|
||||
|
||||
def print_stats():
|
||||
log(f"Cache Size: {len(cache)}, System RAM Utilization: {psutil.virtual_memory().percent}%, Cache Hits: {hits}/{hits+misses}")
|
||||
|
||||
|
||||
def cached_wrapper(inner_func):
|
||||
|
||||
@ -48,6 +51,7 @@ def cached_wrapper(inner_func):
|
||||
def invalidate_caches(scrobbletime):
|
||||
cleared, kept = 0, 0
|
||||
for k in cache.keys():
|
||||
# VERY BIG TODO: differentiate between None as in 'unlimited timerange' and None as in 'time doesnt matter here'!
|
||||
if (k[3] is None or scrobbletime >= k[3]) and (k[4] is None or scrobbletime <= k[4]):
|
||||
cleared += 1
|
||||
del cache[k]
|
||||
|
Loading…
x
Reference in New Issue
Block a user