Shrink the cache if applicable. This only applies if a user has modified the cache size, otherwise it just returns. Returns: None
()
| 10 | |
| 11 | |
| 12 | def _shrink_cache(): |
| 13 | """Shrink the cache if applicable. |
| 14 | |
| 15 | This only applies if a user has modified the cache size, otherwise it |
| 16 | just returns. |
| 17 | |
| 18 | Returns: |
| 19 | |
| 20 | None |
| 21 | |
| 22 | """ |
| 23 | global _local_storage |
| 24 | |
| 25 | try: |
| 26 | cache = _local_storage.cache |
| 27 | except AttributeError: |
| 28 | return |
| 29 | |
| 30 | diff = len(cache) - get_cache_size() |
| 31 | |
| 32 | if diff > 0: |
| 33 | for _ in py3range(diff): |
| 34 | cache.popitem(last=False) |
| 35 | |
| 36 | |
| 37 | def cache_item(key, product, value): |
no test coverage detected