From 97c83fbef4adf5effb68d0ed3076228c02281492 Mon Sep 17 00:00:00 2001 From: Fabio Caccamo Date: Fri, 3 Nov 2023 15:34:58 +0100 Subject: [PATCH] Code refactoring. --- treenode/cache.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/treenode/cache.py b/treenode/cache.py index eeda4cb..d85dc5b 100644 --- a/treenode/cache.py +++ b/treenode/cache.py @@ -52,7 +52,8 @@ def query_cache(cls, pk=None, pks=None): def update_cache(cls): + objs = list(cls.objects.all()) ls, d = _get_cached_collections() - ls[cls] = list(cls.objects.all()) - d[cls] = {str(obj.pk): obj for obj in ls[cls]} + ls[cls] = objs + d[cls] = {str(obj.pk): obj for obj in objs} _set_cached_collections(ls, d)