1
0
Fork 0

log which cache items have been pruned

This commit is contained in:
Sean Sube 2023-03-11 08:06:22 -06:00
parent cb2b054fde
commit 8e5d0871c8
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
1 changed files with 7 additions and 2 deletions

View File

@ -47,9 +47,14 @@ class ModelCache:
def prune(self): def prune(self):
total = len(self.cache) total = len(self.cache)
if total > self.limit: overage = total - self.limit
if overage > 0:
removed = self.cache[:overage]
logger.info( logger.info(
"removing models from cache, %s of %s", (total - self.limit), total "removing %s of %s models from cache, %s",
overage,
total,
[m[0] for m in removed],
) )
self.cache[:] = self.cache[-self.limit :] self.cache[:] = self.cache[-self.limit :]
else: else: