Skip to content

feat: add unstorage backend and fix batch operation error propagation#4

Merged
esroyo merged 4 commits into
mainfrom
feat/unstorage
May 19, 2026
Merged

feat: add unstorage backend and fix batch operation error propagation#4
esroyo merged 4 commits into
mainfrom
feat/unstorage

Conversation

@esroyo
Copy link
Copy Markdown
Owner

@esroyo esroyo commented May 17, 2026

Add CachePersistenceUnstorage class wrapping unstorage's Storage interface, exposing 20+ storage drivers through a single adapter.

Fix error handling in Cache.put() and Cache.delete() batch operations: persistence errors now reject the returned promise and are also logged via console.error. Previously errors were caught but the promise never resolved or rejected.

Refactor shared test infrastructure to use runSharedTests() instead of globalThis.caches mutation, eliminating test pollution under --parallel. Use random ephemeral ports to avoid collisions between V8 isolates.

Add CachePersistenceUnstorage class wrapping unstorage's Storage
interface, exposing 20+ storage drivers through a single adapter.

Fix error handling in Cache.put() and Cache.delete() batch operations:
persistence errors now reject the returned promise and are also logged
via console.error. Previously errors were caught but the promise never
resolved or rejected.

Refactor shared test infrastructure to use runSharedTests() instead
of globalThis.caches mutation, eliminating test pollution under
--parallel. Use random ephemeral ports to avoid collisions between
V8 isolates.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

❌ Patch coverage is 83.28267% with 55 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.85%. Comparing base (08b9b2e) to head (3fa35af).

Files with missing lines Patch % Lines
src/unstorage/mod.ts 85.23% 25 Missing and 10 partials ⚠️
src/deno_redis/mod.ts 36.36% 4 Missing and 3 partials ⚠️
src/memory/mod.ts 40.00% 3 Missing and 3 partials ⚠️
src/deno_kv/mod.ts 60.00% 2 Missing and 2 partials ⚠️
src/core/cache.ts 93.61% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #4      +/-   ##
==========================================
- Coverage   84.30%   83.85%   -0.45%     
==========================================
  Files          10       11       +1     
  Lines        1657     1933     +276     
  Branches      206      258      +52     
==========================================
+ Hits         1397     1621     +224     
- Misses        216      253      +37     
- Partials       44       59      +15     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

esroyo added 3 commits May 17, 2026 16:07
Add CachePersistenceQueryOptions with ignoreRetention flag, threaded
through all backends (memory, deno-kv, deno-redis, unstorage, noop)
to allow bypassing stale retention during deletion/cleanup.

Fix CacheStorage.delete() and Cache.put() to use ignoreRetention:true
so retained stale entries are properly cleaned up.

Fix unstorage backend:
- Filter _dbScan to only read index keys (suffixed with _)
- Add defensive _parseIndex for Set/Array driver returns
- Proper asyncDispose for storage cleanup
- Remove unnecessary batch iteration in get/delete
- Bump unstorage 1.14.4 -> 1.17.5

Refactor shared test infrastructure:
- runSharedTests is now async with proper cleanup
- Each backend variant uses scoped blocks with await using
- Add deno-kv and lru-cache drivers to unstorage test suite
- Separate fs-lite base dirs for evict/retain tests
- Uncomment deno-kv benchmarks
Encode cache names with encodeURIComponent in _persistenceKey so that
cache names containing ':' don't break the colon-delimited key format.
Decode in each backend's keys() when extracting cache names.

Refactor unstorage keys() and [Symbol.asyncIterator] to use
_persistenceKey + _joinKey instead of hardcoded prefix strings,
matching the pattern used by other backends.

Isolate parallel test execution by giving native deno_kv and
unstorage deno-kv driver tests separate Deno.Kv database paths,
preventing cross-contamination in --parallel mode.

Restore --parallel flag in test command.
@esroyo esroyo merged commit f56492f into main May 19, 2026
1 of 3 checks passed
@esroyo esroyo deleted the feat/unstorage branch May 19, 2026 00:35
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.

1 participant