MCPcopy
hub / github.com/omkarcloud/botasaurus / get

Method get

botasaurus/cache_storage.py:11–33  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls 5

_get_cache_pathFunction · 0.85
is_item_older_thanMethod · 0.80
_hasFunction · 0.70
_getFunction · 0.70
deleteMethod · 0.45

Tested by

no test coverage detected