Conditions | 6 |
Total Lines | 17 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | |||
20 | def filter(self, record: LogRecord) -> bool: |
||
21 | key = self._record_key(record) |
||
22 | current_time = time.time() |
||
23 | with self._lock: |
||
24 | if key not in self._cache: |
||
25 | self._cache[key] = current_time |
||
26 | self._cache.move_to_end(key) |
||
27 | if len(self._cache) > self.cache_size: |
||
28 | self._cache.popitem(last=False) |
||
29 | return True |
||
30 | elif current_time - self._cache[key] > self.lockout_time: |
||
31 | self._cache[key] = current_time |
||
32 | self._cache.move_to_end(key) |
||
33 | if len(self._cache) > self.cache_size: |
||
34 | self._cache.popitem(last=False) |
||
35 | return True |
||
36 | return False |
||
37 | |||
48 |