From bb6f5d6096ff9e7f31cb3993f87634b4fcc832ed Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Mon, 26 Aug 2024 13:36:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/cache/file_cache.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/apps/common/cache/file_cache.py b/apps/common/cache/file_cache.py index 72b1201d1..4808b31f6 100644 --- a/apps/common/cache/file_cache.py +++ b/apps/common/cache/file_cache.py @@ -61,3 +61,19 @@ class FileCache(BaseCache): if value is None: return None return datetime.timedelta(seconds=math.ceil(expire_time - time.time())) + + def clear_by_application_id(self, application_id): + delete_keys = [] + for key in self.cache.iterkeys(): + value = self.cache.get(key) + if (hasattr(value, + 'application') and value.application is not None and value.application.id is not None and + str( + value.application.id) == application_id): + delete_keys.append(key) + for key in delete_keys: + self.delete(key) + + def clear_timeout_data(self): + for key in self.cache.iterkeys(): + self.get(key)