Skip to content

Introducing a S3 cache adapter #25

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

Merged
merged 7 commits into from
Jun 16, 2025
Merged

Introducing a S3 cache adapter #25

merged 7 commits into from
Jun 16, 2025

Conversation

edoardocavazza
Copy link
Member

We’re introducing a new cache adapter backed by S3, designed for scenarios where cached files need to persist longer and survive application restarts.

Copy link

changeset-bot bot commented Jun 12, 2025

🦋 Changeset detected

Latest commit: 4cd4d07

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@chialab/sveltekit-utils Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov-commenter
Copy link

codecov-commenter commented Jun 12, 2025

Codecov Report

Attention: Patch coverage is 12.59259% with 118 lines in your changes missing coverage. Please review.

Project coverage is 64.60%. Comparing base (e6bac1d) to head (4cd4d07).

Files with missing lines Patch % Lines
packages/utils/src/lib/server/cache/s3.ts 11.94% 118 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (e6bac1d) and HEAD (4cd4d07). Click for more details.

HEAD has 3 uploads less than BASE
Flag BASE (e6bac1d) HEAD (4cd4d07)
6 3
Additional details and impacted files
@@            Coverage Diff             @@
##             next      #25      +/-   ##
==========================================
- Coverage   74.57%   64.60%   -9.98%     
==========================================
  Files          21       22       +1     
  Lines         704      839     +135     
  Branches      162      164       +2     
==========================================
+ Hits          525      542      +17     
- Misses        177      295     +118     
  Partials        2        2              

☔ 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.

Copilot

This comment was marked as outdated.

@edoardocavazza edoardocavazza requested a review from Copilot June 12, 2025 09:02
Copilot

This comment was marked as outdated.

@edoardocavazza edoardocavazza requested a review from Copilot June 12, 2025 09:14
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a new S3-backed cache adapter to support long-lived, restart-surviving cache entries.

  • Implements S3Cache with standard cache operations (get, set, delete, keys, clear, clearPattern) using AWS SDK v3
  • Exposes the adapter via the cache index and updates dependencies to include @aws-sdk/client-s3
  • Records the change in the project’s changelog

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

File Description
packages/utils/src/lib/server/cache/s3.ts New S3Cache class implementing a cache over S3
packages/utils/src/lib/server/cache/index.ts Export the new S3 cache adapter
packages/utils/package.json Added @aws-sdk/client-s3 to dependencies
.changeset/nice-ants-care.md Added changelog entry for the S3 cache adapter
Comments suppressed due to low confidence (2)

packages/utils/src/lib/server/cache/s3.ts:22

  • [nitpick] There are no JSDoc comments for the S3Cache class or its methods. Adding documentation for TTL semantics, keyPrefix usage, and error-handling behavior would improve clarity for consumers.
export class S3Cache<V extends Uint8Array = Uint8Array> extends BaseCache<V> {

packages/utils/src/lib/server/cache/s3.ts:1

  • The new S3Cache adapter lacks any unit or integration tests. Consider adding tests to cover the core operations (get, set, delete, TTL expiration, error paths) to guard against regressions.
import { BaseCache } from './base';

@edoardocavazza edoardocavazza requested a review from fquffio June 13, 2025 13:39
@fquffio
Copy link
Contributor

fquffio commented Jun 13, 2025

@edoardocavazza Would be nice to add some tests… however if not practically feasible let's merge it.

@edoardocavazza edoardocavazza merged commit 0c0f14a into next Jun 16, 2025
6 checks passed
@edoardocavazza edoardocavazza deleted the s3-cache-adapter branch June 16, 2025 10:45
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.

3 participants