Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ cache = SecretCache(config=cache_config, client=client)
secret = cache.get_secret_string('mysecret')
```

#### Forcing a Refresh

The cache normally refreshes a secret only once `secret_refresh_interval` seconds have passed since the last refresh (1 hour by default). Within that window `get_secret_string()` returns the cached value without calling Secrets Manager, so a secret rotated in the meantime will not be picked up until the interval elapses.

`refresh_secret_now()` fetches the secret from Secrets Manager immediately instead of waiting for that interval. It returns `True` if the refresh succeeded, or `False` if it failed, in which case the previously cached value is kept.

```python
refreshed = cache.refresh_secret_now('mysecret') # bool
secret = cache.get_secret_string('mysecret')
```

This call blocks for a few seconds before it retrieves the secret. The short delay is randomized so that many clients refreshing at the same time, such as after a rotation, do not all call Secrets Manager at once. If a recent refresh failed, the call also waits for the pending retry delay, up to a maximum of 10 seconds. Because of this, call `refresh_secret_now()` when you have reason to believe the cached secret is out of date rather than before every retrieval.

#### Cache Configuration

You can configure the cache config object with the following parameters:
Expand Down
Loading