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(cloudflare-kv-binding): support ttl for setItem #470

Merged
merged 10 commits into from
Sep 4, 2024

Conversation

barberj
Copy link
Contributor

@barberj barberj commented Jul 31, 2024

Nitro calls setItem with key and an entry object. The entry object has keys value, integrity, mtime, and expires. Set ttl on TransactionOptions from value before calling the driver's setItem.

resolves #32 & Nitro#2510

@barberj barberj force-pushed the cloudflare-kv-expiration_ttl branch 10 times, most recently from 81d4b54 to 5ee9bb0 Compare August 2, 2024 14:44
@barberj barberj marked this pull request as ready for review August 2, 2024 14:44
@barberj barberj force-pushed the cloudflare-kv-expiration_ttl branch 3 times, most recently from 96c8822 to 1024281 Compare August 2, 2024 14:58
@barberj barberj changed the title Cloudflare KV Opts feat: update cloudflare kv driver to set expiration when setting items Aug 2, 2024
The value is stringify when passed to the storage driver. Parse it looking for an expires value. If expires value exists, set expirationTtl in Cloudflare KV store
- Add the event's expires key to the transcation options when calling setItem for use with the driver.
- Update Cloudflare KV setItem to use TransactionOption's ttl for expirationTtl value when setting the key.
@barberj barberj force-pushed the cloudflare-kv-expiration_ttl branch from 1024281 to 4138297 Compare August 6, 2024 01:12
src/storage.ts Outdated Show resolved Hide resolved
src/drivers/cloudflare-kv-binding.ts Outdated Show resolved Hide resolved
@pi0 pi0 changed the title feat: update cloudflare kv driver to set expiration when setting items feat(cloudflare-kv): infer expirationTtl from ttl option Sep 4, 2024
@pi0 pi0 changed the title feat(cloudflare-kv): infer expirationTtl from ttl option feat(cloudflare-kv-binding): support ttl for setItem Sep 4, 2024
@pi0 pi0 self-requested a review September 4, 2024 09:14
@pi0 pi0 merged commit f817e0a into unjs:main Sep 4, 2024
2 checks passed
Copy link

codecov bot commented Sep 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 57.94%. Comparing base (4d61c78) to head (953cc47).
Report is 60 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #470      +/-   ##
==========================================
- Coverage   65.05%   57.94%   -7.12%     
==========================================
  Files          39       38       -1     
  Lines        4055     3091     -964     
  Branches      487      514      +27     
==========================================
- Hits         2638     1791     -847     
+ Misses       1408     1291     -117     
  Partials        9        9              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Use Cloudflare KV native meta
2 participants