Closed
Description
Use case
When testing code that uses the Parameters utility, and specifically some of the high-order functions like getParameter
or getAppConfig
, it's important that users have the ability to control cache eviction.
Right now users can manually import the DEFAULT_PROVIDERS
object and manually clean the cache of each provider, i.e.:
import { DEFAULT_PROVIDERS } from '@aws-lambda-powertools/parameters';
for (const provider of Object.values(DEFAULT_PROVIDERS)) {
provider.clearCache();
}
This however results in unnecessary boilerplate code. There is an opportunity to provide a better DX by exposing a clearCaches
helper function that incapsulate this code as well as any future underlying logic required to clean cache.
Solution/User Experience
import { clearCaches } from '@aws-lambda-powertools/parameters';
clearCaches();
The function will iterate the DEFAULT_PROVIDERS
and call the clearCache
method on each one.
Alternative solutions
N/A
Acknowledgment
- This feature request meets Lambda Powertools Tenets
- Should this be considered in other Lambda Powertools languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.