Skip to content

Feature request: add clearCaches method for testing #1381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 2 tasks
dreamorosi opened this issue Mar 25, 2023 · 1 comment · Fixed by #1382
Closed
1 of 2 tasks

Feature request: add clearCaches method for testing #1381

dreamorosi opened this issue Mar 25, 2023 · 1 comment · Fixed by #1382
Assignees
Labels
completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility parameters This item relates to the Parameters Utility

Comments

@dreamorosi
Copy link
Contributor

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

Future readers

Please react with 👍 and your use case to help us understand customer demand.

@dreamorosi dreamorosi added parameters This item relates to the Parameters Utility feature-request This item refers to a feature request for an existing or new utility confirmed The scope is clear, ready for implementation labels Mar 25, 2023
@dreamorosi dreamorosi added this to the Parameters - GA Release milestone Mar 25, 2023
@dreamorosi dreamorosi self-assigned this Mar 25, 2023
@dreamorosi dreamorosi linked a pull request Mar 25, 2023 that will close this issue
13 tasks
@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in AWS Lambda Powertools for TypeScript Mar 25, 2023
@github-actions
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added the pending-release This item has been merged and will be released soon label Mar 25, 2023
@dreamorosi dreamorosi removed the confirmed The scope is clear, ready for implementation label Mar 25, 2023
@dreamorosi dreamorosi added completed This item is complete and has been merged/shipped and removed pending-release This item has been merged and will be released soon labels Apr 11, 2023
@dreamorosi dreamorosi moved this from Coming soon to Shipped in AWS Lambda Powertools for TypeScript Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility parameters This item relates to the Parameters Utility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant