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

Use model reference from env when it is available #161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

EiNSTeiN-
Copy link

The get_session_model method will store a reference to the model in request.env[SESSION_RECORD_KEY] when the session is loaded. Later on when saving the session, write_session calls get_session_model, which again calls the active record finder methods to load the model.

In a standard Rails app, this would presumably hit the active record cache and not hit mysql twice, but if the active record cache is invalidated during the request or if @@session_class#find_by_session_id was overloaded to do anything else (like perhaps read from an external cache), then the app will end up doing unnecessary work.

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