Skip to content

Feature request: add clearCaches method for testing #1381

Closed
@dreamorosi

Description

@dreamorosi

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.

Metadata

Metadata

Assignees

Labels

completedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityparametersThis item relates to the Parameters Utility

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions