Return the cache class for the given size.
(
size: int,
)
| 78 | |
| 79 | |
| 80 | def create_cache( |
| 81 | size: int, |
| 82 | ) -> t.Optional[t.MutableMapping[t.Tuple[weakref.ref, str], "Template"]]: |
| 83 | """Return the cache class for the given size.""" |
| 84 | if size == 0: |
| 85 | return None |
| 86 | |
| 87 | if size < 0: |
| 88 | return {} |
| 89 | |
| 90 | return LRUCache(size) # type: ignore |
| 91 | |
| 92 | |
| 93 | def copy_cache( |