Stateful server #4096
Replies: 2 comments
-
You could use something like lru-cache package to keep an in memory cache you can share across requests while not filling the memory, or just a plain object works too. I’m not sure this is something Remix will provide since they don’t provide the database too, and it’s quite easy to create your shared object in the server. |
Beta Was this translation helpful? Give feedback.
-
Thanks for you input, I did check the docs again, and I think that here it says that you can pass an object when configuring the request handler: https://remix.run/docs/en/v1/other-api/adapter#createrequesthandler and then, the context can be accessed with: export async function loader({ context }: LoaderArgs) {
// some code here
} This fulfills my use case fully. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Would like a stateful context shared at least between the loaders and the server code, I am willing to put in the work if anyone is interested. For starters I would add a popular Dependency Injection container.
Edit: currently only the database, the Cloudflare KV and some other external solution for sharing state is provided. Would be great if that running server could use some memory to pass data when answering requests.
Beta Was this translation helpful? Give feedback.
All reactions