Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
/frameworkPublic archive

feat(nuxt): filter support for clearNuxtData - #7323

Merged
pi0 merged 1 commit into
nuxt:mainfrom
cawa-93:feat/clearNuxtDataByFilter
Sep 7, 2022
Merged

feat(nuxt): filter support for clearNuxtData#7323
pi0 merged 1 commit into
nuxt:mainfrom
cawa-93:feat/clearNuxtDataByFilter

Conversation

@cawa-93

Copy link
Copy Markdown
Contributor

🔗 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

netlifyBot commented Sep 7, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs ready!

NameLink
🔨 Latest commitba4828c
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/63188baaed3c8800081e3be1
😎 Deploy Previewhttps://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
Copy Markdown
Member

I do like the idea of a filter method ☺️

@atinux

Copy link
Copy Markdown
Member

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

@cawa-93

Copy link
Copy Markdown
ContributorAuthor

pi0
pi0 approved these changes Sep 7, 2022
@pi0

pi0 commented Sep 7, 2022

Copy link
Copy Markdown
Member

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

@pi0pi0 changed the title feat: add filter for clearNuxtDatafeat(nuxt): filter support for clearNuxtDataSep 7, 2022
@pi0
pi0 merged commit 6b3a1a4 into nuxt:mainSep 7, 2022
@cawa-93
cawa-93 deleted the feat/clearNuxtDataByFilter branch September 7, 2022 13:32
This was referenced Sep 9, 2022
Sign up for freeto 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.

4 participants

@cawa-93@atinux@pi0@danielroe