Skip to content
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

feat: add clear method to cache object type #2950

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

shhonarmandi
Copy link

@shhonarmandi shhonarmandi commented Apr 25, 2024

This commit updates the type definition of the Cache object to align with the native JavaScript Map data structure. This offers users access to clear method available on Map.

cache.clear(): Removes all key-value pairs from the cache (useful scenarios include user logout).

Relevant issue:
#2877

Copy link

codesandbox-ci bot commented Apr 25, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@koba04
Copy link
Collaborator

koba04 commented May 1, 2024

Thank you for your PR!
As you mentioned, although the default Cache object is implemented with Map internally, it doesn't mean the Cache must be Map. We intentionally restrict the Cache interface to only APIs SWR uses internally so that users can implement their own Cache store without relying on Map.

Let me consider the clearing cache feature separately.

@shhonarmandi shhonarmandi changed the title fix: cache map object type feat: add clear method to cache object type May 2, 2024
@shhonarmandi
Copy link
Author

shhonarmandi commented May 2, 2024

@koba04

Thank you for your feedback.

I updated the pull request and removed unnecessary methods and properties as you mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants