cache
Cache utilities.
MemoryCache
dataclass
¶
Cache results of a method call for a given key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ttl
|
float
|
|
5.0
|
cache
|
dict[tuple[Any], tuple[Any, float]]
|
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) |
<class 'dict'>
|
Source code in src/stac_auth_proxy/utils/cache.py
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 60 61 62 63 64 65 66 67 68 69 |
|
__contains__(key: Any) -> bool
¶
Check if a key is in the cache and is not expired.
Source code in src/stac_auth_proxy/utils/cache.py
40 41 42 43 44 45 46 |
|
__getitem__(key: Any) -> Any
¶
Get a value from the cache if it is not expired.
Source code in src/stac_auth_proxy/utils/cache.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
__setitem__(key: Any, value: Any)
¶
Set a value in the cache.
Source code in src/stac_auth_proxy/utils/cache.py
35 36 37 38 |
|
get(key: Any) -> Any
¶
Get a value from the cache.
Source code in src/stac_auth_proxy/utils/cache.py
48 49 50 51 52 53 |
|
get_value_by_path(obj: dict, path: str, default: Any = None) -> Any
¶
Get a value from a dictionary using dot notation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
dict
|
The dictionary to search in |
required |
path
|
str
|
The dot notation path (e.g. "payload.sub") |
required |
default
|
Any
|
Default value to return if path doesn't exist |
None
|
Returns¶
The value at the specified path or default if path doesn't exist
Source code in src/stac_auth_proxy/utils/cache.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|