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