(self)
| 16 | self._threshold = threshold |
| 17 | |
| 18 | def _prune(self): |
| 19 | if len(self._cache) > self._threshold: |
| 20 | now = time.time() |
| 21 | toremove = [] |
| 22 | for idx, (key, (expires, _)) in enumerate(self._cache.items()): |
| 23 | if (expires != 0 and expires <= now) or idx % 3 == 0: |
| 24 | toremove.append(key) |
| 25 | for key in toremove: |
| 26 | self._cache.pop(key, None) |
| 27 | |
| 28 | def _normalize_timeout(self, timeout): |
| 29 | if timeout is None: |