From ed512fe7d93640eba6f0a3c4f28e53488955ce91 Mon Sep 17 00:00:00 2001 From: SaiTejaKundety Date: Tue, 22 Sep 2026 15:05:40 -0700 Subject: [PATCH 1/2] docs: document refresh_secret_now() in the README --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 6ad6107..c39d2b1 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,17 @@ 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') +``` + #### Cache Configuration You can configure the cache config object with the following parameters: From 2778ce6a127416e54f1e4e157cb5c946306ba765 Mon Sep 17 00:00:00 2001 From: SaiTejaKundety Date: Tue, 22 Sep 2026 15:11:17 -0700 Subject: [PATCH 2/2] docs: document refresh_secret_now() in the README --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c39d2b1..1e3a87b 100644 --- a/README.md +++ b/README.md @@ -119,13 +119,15 @@ secret = cache.get_secret_string('mysecret') 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. +`refresh_secret_now()` fetches the secret from Secrets Manager immediately instead of waiting for that interval, and stores the retrieved value in the cache so subsequent retrievals return it. 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. If a recent refresh failed, the call also waits for the pending retry delay, up to a maximum of 10 seconds. + #### Cache Configuration You can configure the cache config object with the following parameters: