Skip to content

Commit 4ebace8

Browse files
committed
docs(parameters): surface how to change cache TTL
1 parent a458459 commit 4ebace8

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

docs/utilities/parameters.md

+28-3
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,34 @@ The following will retrieve the latest version and store it in the cache.
8888

8989
## Advanced
9090

91+
### Adjusting cache TTL
92+
93+
By default, we cache parameters retrieved in-memory for 5 seconds.
94+
95+
You can adjust how long we should keep values in cache by using the param `max_age`, when using `get()` or `get_multiple` methods across all providers.
96+
97+
=== "app.py"
98+
99+
```python hl_lines="9"
100+
from aws_lambda_powertools.utilities import parameters
101+
from botocore.config import Config
102+
103+
config = Config(region_name="us-west-1")
104+
ssm_provider = parameters.SSMProvider(config=config)
105+
106+
def handler(event, context):
107+
# Retrieve a single parameter
108+
value = ssm_provider.get("/my/parameter", max_age=60) # 1 minute
109+
110+
# Retrieve multiple parameters from a path prefix
111+
values = ssm_provider.get_multiple("/my/path/prefix")
112+
for k, v in values.items():
113+
print(f"{k}: {v}")
114+
```
115+
91116
### Always fetching the latest
92117

93-
By default, we cache parameters retrieves for 5 seconds. If you'd like to override this behaviour and always fetch the latest parameter from the store, use `force_fetch` param.
118+
If you'd like to always ensure you fetch the latest parameter from the store regardless if already available in cache, use `force_fetch` param.
94119

95120
=== "app.py"
96121

@@ -133,8 +158,8 @@ The AWS Systems Manager Parameter Store provider supports two additional argumen
133158

134159
| Parameter | Default | Description |
135160
|---------------|---------|-------------|
136-
| **decrypt** | `False` | Will automatically decrypt the parameter. |
137-
| **recursive** | `True` | For `get_multiple()` only, will fetch all parameter values recursively based on a path prefix. |
161+
| **decrypt** | `False` | Will automatically decrypt the parameter.
162+
| **recursive** | `True` | For `get_multiple()` only, will fetch all parameter values recursively based on a path prefix.
138163

139164
> **Example**
140165

0 commit comments

Comments
 (0)