Skip to content

Conversation

james-elicx
Copy link
Collaborator

Context

At the moment, the KV instance that is used by the cache handler is assigned to the class as a static property as part of the code patch that happens. We should move this to happen during the creation of a new instance of the class.

Normally, all logic related to setting up the cache handler would happen within the cache handler itself, whereas it currently happens externally. This also means that in the long-term, it makes it easier to extend the cache handler to support additional mechanisms/customisability should we desire (e.g. R2).

Changes

  • Moves the cache handler to the templates dir and builds it to the output directory in the cli with an inlined env var for the name of the KV binding.
  • Changes the patch to import the cache handler from the output directory instead of the cli.
  • Retrieves KV instance in constructor.

Copy link

changeset-bot bot commented Oct 7, 2024

🦋 Changeset detected

Latest commit: 0dbf79c

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

This PR includes changesets to release 1 package
Name Type
@opennextjs/cloudflare Patch

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

Copy link

pkg-pr-new bot commented Oct 7, 2024

Open in Stackblitz

pnpm add https://pkg.pr.new/@opennextjs/cloudflare@72

commit: 0dbf79c

@james-elicx james-elicx marked this pull request as ready for review October 7, 2024 22:30
Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.

It looks great with a few minor comments.


A bit off-topic to this PR but more details on our plan since you are a major contributor to this repo:

The plan is that we move/re-use code from opennextjs-aws.

By sharing code and architecture both repos will benefit for the fixes/features.

The first notable change will be that we will run the routing + middleware layer that is not currently supported in this repo.

I hope to have some code ready later this week.

Thanks for all you contribs!

Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

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

Thanks!

@vicb vicb merged commit 83abcfe into main Oct 8, 2024
7 checks passed
@vicb vicb deleted the james/cache-handle-kv-instance branch October 8, 2024 07:50
__NEXT_PRIVATE_STANDALONE_CONFIG?: string;
SKIP_NEXT_APP_BUILD?: string;
NEXT_PRIVATE_DEBUG_CACHE?: string;
__OPENNEXT_KV_BINDING_NAME: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

@james-elicx Is this documented already?
If not, would you mind sending a PR?
Also maybe add a default value.
Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The intention was for this to just be used internally to inline a value into the cache handler, but yeah, it would make sense to let users use it as well

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.

2 participants