Read data from a cache file.
(func, key_data, raise_exception=True)
| 283 | |
| 284 | @staticmethod |
| 285 | def get(func, key_data, raise_exception=True): |
| 286 | """Read data from a cache file.""" |
| 287 | |
| 288 | # resolve user errors |
| 289 | if isinstance(key_data, list): |
| 290 | return Cache.get_items(func, key_data) |
| 291 | |
| 292 | _create_cache_directory_if_not_exists(func) |
| 293 | path = _get_cache_path(func, key_data) |
| 294 | if _has(path): |
| 295 | try: |
| 296 | return _get(path) |
| 297 | except CacheMissException: |
| 298 | return None |
| 299 | |
| 300 | if raise_exception: |
| 301 | raise CacheMissException(path) |
| 302 | return None |
| 303 | @staticmethod |
| 304 | def get_item_by_hash(func, hash, raise_exception=True): |
| 305 | """Read data from a cache file.""" |