Add last_request_at_update_interval option to Timeoutable - #5857
Open
albertski wants to merge 1 commit into
Open
Add last_request_at_update_interval option to Timeoutable#5857albertski wants to merge 1 commit into
albertski wants to merge 1 commit into
Conversation
When set, last_request_at is only updated if more than session_update_interval has elapsed since the last write
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
last_request_at_update_intervalconfiguration option to the:timeoutablemodule. When set,last_request_atis only written to the session if the specified interval has elapsed since the last write, reducing unnecessary database writes on high-traffic applications.Usage
The interval must be set to a value less than timeout_in to avoid users being timed out prematurely.
Motivation
A recent optimization in
activerecord-session_store(#166) aimed to avoid unnecessary database writes by skipping session saves when the data had not changed. The intention of this optimization is valid. There is no reason to write to the database on every request, particularly when making frequent API or GraphQL calls.That optimization introduced a bug (#236) where in-place mutations to session data were silently dropped, which I addressed in (#238).
This PR allows applications that use
Timeoutableto take advantage of the optimizations.