Returns: {"data": value} if cache hit (value can be None) None if cache miss or expired
(func_name: str, key_data, expires_in: Optional[timedelta] = None)
| 9 | |
| 10 | @staticmethod |
| 11 | def get(func_name: str, key_data, expires_in: Optional[timedelta] = None) -> Optional[Dict[str, Any]]: |
| 12 | """ |
| 13 | Returns: |
| 14 | {"data": value} if cache hit (value can be None) |
| 15 | None if cache miss or expired |
| 16 | """ |
| 17 | path = _get_cache_path(func_name, key_data) |
| 18 | if _has(path): |
| 19 | if expires_in is not None: |
| 20 | if Cache.is_item_older_than( |
| 21 | func_name, |
| 22 | key_data, |
| 23 | days=expires_in.days, |
| 24 | seconds=expires_in.seconds, |
| 25 | microseconds=expires_in.microseconds, |
| 26 | ): |
| 27 | Cache.delete(func_name, key_data) |
| 28 | return None |
| 29 | try: |
| 30 | return {"data": _get(path)} |
| 31 | except CacheMissException: |
| 32 | return None |
| 33 | return None |
| 34 | |
| 35 | @staticmethod |
| 36 | def put(func_name: str, key_data, data: Any) -> None: |
nothing calls this directly
no test coverage detected