Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

feat(nuxt): filter support for clearNuxtData #7323

Merged
merged 1 commit into from Sep 7, 2022
Merged

feat(nuxt): filter support for clearNuxtData #7323

merged 1 commit into from Sep 7, 2022

Conversation

cawa-93
Copy link
Contributor

@cawa-93 cawa-93 commented Sep 7, 2022

πŸ”— Linked issue

Continuation of #5227

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Uncovered use case:
Remove cache for several unknown keys. Example: you have app with posts and filter for posts. Each query for posts saved in cache in uniq key, like posts.list-{param1:1}, posts.list-{param2:2}, posts.list-{param1:1,param2:3} (nuxt-trpc works llike that). In this case you may want clear data for all keys posts.list-*.
May be clearNuxtData should also accept function to filter keys?

clearNuxtData(key => key.startsWith('posts.list'))

Or provide another method to get all keys in cache and filter it manually:

clearNuxtData(
  getNuxtDataKeys().filter(key => key.startsWith('posts.list'))
)

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@netlify
Copy link

netlify bot commented Sep 7, 2022

βœ… Deploy Preview for nuxt3-docs ready!

Name Link
πŸ”¨ Latest commit ba4828c
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/63188baaed3c8800081e3be1
😎 Deploy Preview https://deploy-preview-7323--nuxt3-docs.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@Atinux
Copy link
Member

Atinux commented Sep 7, 2022

I do like the idea of a filter method ☺️

@Atinux
Copy link
Member

Atinux commented Sep 7, 2022

Wondering if this could be applied also to refreshNuxtData(): https://v3.nuxtjs.org/api/utils/refresh-nuxt-data

@cawa-93
Copy link
Contributor Author

cawa-93 commented Sep 7, 2022

@pi0
Copy link
Member

pi0 commented Sep 7, 2022

LGTM. Supporting for refreshNuxtData is also good idea. We can implement similar for fallback when no keys are set. (PR welcome)

@pi0 pi0 changed the title feat: add filter for clearNuxtData feat(nuxt): filter support for clearNuxtData Sep 7, 2022
@pi0 pi0 merged commit 6b3a1a4 into nuxt:main Sep 7, 2022
@cawa-93 cawa-93 deleted the feat/clearNuxtDataByFilter branch September 7, 2022 13:32
This was referenced Sep 9, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants