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

[FEATURE] Store sessions in Redis #17

Open
JakubKoralewski opened this issue Jan 15, 2021 · 4 comments
Open

[FEATURE] Store sessions in Redis #17

JakubKoralewski opened this issue Jan 15, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@JakubKoralewski
Copy link
Owner

Currently sessions are stored in Postgres despite having a Redis instance available.

adapter: Adapters.Prisma.Adapter({ prisma }),

Related:

nextauthjs/next-auth#544

@JakubKoralewski JakubKoralewski added the enhancement New feature or request label Jan 15, 2021
@gmwill934
Copy link

Anyway we could support this?

@gmwill934
Copy link

How would it work?.

Store sessions on redis for fast server side session validation, but, choosing another database and adapter to work with the actual data.

An example could be postgres + prisma (adapter) and storing sessions on redis.

@JakubKoralewski
Copy link
Owner Author

JakubKoralewski commented Oct 27, 2021

Hi! I don't develop features for this project anymore, but if you'd like to try this I am happy to help you along the way.

It's been a while since I wrote/read this code, but I think you'd need to write a custom adapter for next-auth which will know how to associate session data with user id's from e.g. Postgres; and know when to talk to Redis vs when to Postgres. I think it's more complicated with next-auth than it would be without tbh, since when implementing those functions like createUser you'd need to talk to Postgres, but createSession you'd want to put in Redis. You'd probably need to also store users in Redis to eliminate talking to Postgres when logging in, but then you have the problem of 2 copies of data, and issues with synchronization... Interesting problem.

@gmwill934
Copy link

What about using my custom backend that already has everything set up? Pretty much I will just be using next auth to store server side sessions on the client (cookies). Does that seems feasible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants