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(vercel-kv): support ttl for setItem #269

Merged
merged 4 commits into from
Aug 7, 2023
Merged

feat(vercel-kv): support ttl for setItem #269

merged 4 commits into from
Aug 7, 2023

Conversation

azophy
Copy link
Contributor

@azophy azophy commented Jul 8, 2023

here we add new option 'ttl' both for driver setup config & for set() method. the interface & implementation took notes from existing redis driver.

πŸ”— Linked issue

this resolve #266

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 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)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

I have implemented the proposal in #266 . To test it, I have run pnpm vitest run --coverage by giving my Vercel KV's credential, and the result shows that it has passed completely.

image

However because it only uses existing Vercel KV's test suite, it shouldn't have tested the new key expiration functionality. And I'm not sure how I should create the test for this particular feature. I've looked into Redis driver test suite, but I couldn't find section for testing key expiration which I could follow. Maybe other maintainers could give me some pointer? @pi0 @Hebilicious

πŸ“ Checklist

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

here we add new option 'ttl' both for driver setup config & for `set()`
method. the interface & implementation took notes from existing redis
driver.
@nuxt-studio
Copy link

nuxt-studio bot commented Jul 8, 2023

βœ… Live Preview ready!

Name Edit Preview Latest Commit
unstorage Edit on Studio β†—οΈŽ View Live Preview b040061

@Hebilicious
Copy link
Member

Linking #262 for reference. Do we go with this syntax for every driver @pi0 ?

@Hebilicious Hebilicious added vercel-kv enhancement New feature or request labels Jul 8, 2023
Copy link
Member

@Hebilicious Hebilicious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the default ttl options !

@azophy
Copy link
Contributor Author

azophy commented Jul 9, 2023

Right now, I've just replaced unstorage dependency for one of my NuxtJs project with a github branch based on this PR. I know that this kind of manual testing is not ideal, but currently this is the best approach I could came out with to verify that this code have worked.

my project: https://papan-skor.vercel.app
github repo: https://github.com/azophy/papan-skor
temporary github branch that serve build of this PR: https://github.com/azophy/unstorage/tree/feat/vercelkv-ttl-build
commit that introduce dependency replacement: azophy/papan-skor@67cc078

I verify that the new ttl option is indeed worked by manually checking the results of Redis TTL command from my Vercel KV dashboard

Screenshot from my Vercel KV Dashboard

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@pi0 pi0 changed the title feat(vercel-kv): add key expiration option feat(vercel-kv): support ttl for setItem Aug 7, 2023
@codecov
Copy link

codecov bot commented Aug 7, 2023

Codecov Report

Merging #269 (b040061) into main (a0a1cdd) will increase coverage by 0.39%.
Report is 2 commits behind head on main.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #269      +/-   ##
==========================================
+ Coverage   76.55%   76.94%   +0.39%     
==========================================
  Files          26       26              
  Lines        3169     3223      +54     
  Branches      473      473              
==========================================
+ Hits         2426     2480      +54     
  Misses        742      742              
  Partials        1        1              
Files Changed Coverage Ξ”
src/index.ts 100.00% <100.00%> (ΓΈ)

@pi0 pi0 merged commit 0e6e023 into unjs:main Aug 7, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

key expiration support for vercel-kv driver
3 participants