1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""CombResult dataclass returned by client get() calls."""
"""Result of a ``get`` query to the beachcomber daemon.
Attributes:
ok: Whether the daemon responded without error (always ``True``
when returned from the client — errors raise exceptions).
data: The cached value. ``None`` on a cache miss. May be a string,
number, bool, or dict depending on the provider and key.
age_ms: How many milliseconds old the cached value is. ``0`` on a
miss.
stale: ``True`` when the value is past its TTL but no fresh value
is available yet.
error: Error message string when ``ok`` is ``False``. The client
raises :class:`~beachcomber.exceptions.ServerError` for these,
so callers typically do not see this field set.
"""
: = True
: = None
: = 0
: = False
: = None
"""``True`` when the cache contains a value for this key."""
return is not None
"""Access a field from dict data by subscript.
Useful when querying a full provider that returns an object,
e.g. ``result["branch"]`` after ``client.get("git")``.
Args:
key: Field name to look up in the data dict.
Returns:
The field value.
Raises:
TypeError: If ``data`` is not a dict.
KeyError: If ``key`` is not present in the dict.
"""
return