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

Vercel Data Cache - Middleware Adapter #3

Closed
wants to merge 2 commits into from
Closed

Conversation

ah100101
Copy link

@ah100101 ah100101 commented Jan 2, 2025

This pull request adds a Vercel Data Cache adapter to Catalyst.

Data Cache Enhancements:

  • Added a new VercelDataCacheAdapter class to handle caching with Vercel's data cache, including methods for setting and getting cache values (core/lib/kv/adapters/vercel-data-cache.ts).
  • Introduced the core vdc lib and getComputeCache function to manage cache operations, including fetching and setting cache values with headers and revalidation (core/lib/vdc/index.ts).

KV Adapter Modifications:

  • Modified the KV class to accept a NextRequest object and set it via the setRequest method. This allows the KV adapter to handle requests (core/lib/kv/index.ts). [1] [2]
  • Updated the createKVAdapter function to conditionally return the VercelDataCacheAdapter based on an environment variable (core/lib/kv/index.ts). [1] [2]
  • Added a setRequest method to the KvAdapter interface to support request handling (core/lib/kv/types.ts).

Middleware Updates:

  • Updated the withRoutes middleware to create and use a KV instance with the current request (core/middlewares/with-routes.ts). [1] [2] [3] [4] [5] [6]

- Added `VercelDataCacheAdapter` kv adapter
- Updated `KV` class to accept a `NextRequest` and set it for adapters.
- Introduced `createKV` factory function to instantiate `KV` with request context.
- Modified middleware to utilize the new `createKV` function for route handling.
Copy link

vercel bot commented Jan 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
catalyst ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 2, 2025 11:34pm

@ah100101 ah100101 changed the title Vercel Data Cache - KV Adapter Vercel Data Cache - Middleware Adapter Jan 2, 2025
@ah100101 ah100101 closed this Jan 3, 2025
@ah100101 ah100101 deleted the vdc-adapter branch January 3, 2025 00:59
@ah100101 ah100101 restored the vdc-adapter branch January 3, 2025 01:38
@ah100101 ah100101 deleted the vdc-adapter branch January 3, 2025 01:41
@ah100101 ah100101 restored the vdc-adapter branch January 3, 2025 01:44
@ah100101 ah100101 deleted the vdc-adapter branch January 3, 2025 01:52
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