feat: add unstorage backend and fix batch operation error propagation#4
Merged
Conversation
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 Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.