Skip to content

Commit

Permalink
Prefer to use query_parser itself as the cache key. (#2058)
Browse files Browse the repository at this point in the history
Change the cache hash table to use `compare_by_identity` for improved
semantics/performance.
  • Loading branch information
ioquatix committed Mar 16, 2023
1 parent f75d08e commit 5f90c33
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/rack/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def parseable_data?
# behaviour. This includes sub-classes that override query_parser or
# expand_params.
def cache_key
query_parser.class
query_parser
end

# Given a current input value, and a validity key, check if the cache
Expand Down Expand Up @@ -560,7 +560,8 @@ def cache_key

# If the cache was not defined for this cache key, then create a new cache:
unless cache
set_header(key, cache = {})
cache = Hash.new.compare_by_identity
set_header(key, cache)
end

begin
Expand Down

0 comments on commit 5f90c33

Please sign in to comment.