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(cache): allow async getKey option in cache utils #878

Merged
merged 1 commit into from
Jan 25, 2023

Conversation

MiniDigger
Copy link
Contributor

πŸ”— Linked issue

#875

❓ 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

Example:

export default defineCachedEventHandler(async () => {
  await new Promise((resolve) => setTimeout(resolve, 1000));
  console.log("event called")
  return `Response generated at ${new Date().toISOString()} (took 1 second)`;
}, {
  maxAge: 600,
  getKey: async (e) => {
    await new Promise((resolve) => setTimeout(resolve, 500));
    console.log("getKey called")
    return e.node.req.url
  }
});

usecase further explained in #875

I am not sure where this could be mentioned in the docs, should be obvious by the typing that promises/async are allowed?

πŸ“ Checklist

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

@pi0 pi0 changed the title feat: allow async getKey option in cache utils feat(cache): allow async getKey option in cache utils Jan 25, 2023
@codecov
Copy link

codecov bot commented Jan 25, 2023

Codecov Report

Merging #878 (4a9ba0d) into main (f5a5a8e) will decrease coverage by 0.09%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #878      +/-   ##
==========================================
- Coverage   67.42%   67.34%   -0.09%     
==========================================
  Files          59       59              
  Lines        5852     5852              
  Branches      633      632       -1     
==========================================
- Hits         3946     3941       -5     
- Misses       1897     1901       +4     
- Partials        9       10       +1     
Impacted Files Coverage Ξ”
src/rollup/config.ts 91.66% <0.00%> (-0.93%) ⬇️
src/utils/index.ts 52.35% <0.00%> (-0.53%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@pi0 pi0 merged commit 2c52c62 into nitrojs:main Jan 25, 2023
@pi0
Copy link
Member

pi0 commented Jan 25, 2023

Thanks!

@MiniDigger MiniDigger deleted the feat/async-getkey branch January 25, 2023 11:55
@MiniDigger
Copy link
Contributor Author

thank you for the awesome project and speed reviews! πŸš€

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