[11.x] add optional prefix for cache key#53448
Merged
taylorotwell merged 2 commits intolaravel:11.xfrom Nov 9, 2024
Merged
Conversation
if a user does not decide to use a dedicated cache store for their password resets, there's a risk of collision/overwriting of the cache keys in the default cache store, since we are just using the user's email. this allows the user to set an optional config value to use a prefix on the cache key.
Member
|
Would it not be a bit easier to just put them in the cache as something like |
Contributor
Author
|
having some low-collision chance default seems fine to me |
browner12
added a commit
to browner12/framework
that referenced
this pull request
Jun 24, 2025
this is mostly a rollback of laravel#53448 per Taylor's request. rather than allowing an optional prefix, we'll use a deterministic hash of the user's email for our cache key. this should make the chance of a collision if no dedicated store is used statistically insignificant. I've also opted to extract out a `makeCacheKey()` method here mainly to reduce the duplicated code and help prevent bugs from divergence. however, this could possibly help userland override the cache key generation. maybe I'm overthinking that, maybe it's honestly not a problem.
taylorotwell
added a commit
that referenced
this pull request
Jun 25, 2025
* remove the "prefix" option for cache password resets this is mostly a rollback of #53448 per Taylor's request. rather than allowing an optional prefix, we'll use a deterministic hash of the user's email for our cache key. this should make the chance of a collision if no dedicated store is used statistically insignificant. I've also opted to extract out a `makeCacheKey()` method here mainly to reduce the duplicated code and help prevent bugs from divergence. however, this could possibly help userland override the cache key generation. maybe I'm overthinking that, maybe it's honestly not a problem. * formatting --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
mohammad-fouladgar
pushed a commit
to mohammad-fouladgar/framework
that referenced
this pull request
Jul 22, 2025
…56127) * remove the "prefix" option for cache password resets this is mostly a rollback of laravel#53448 per Taylor's request. rather than allowing an optional prefix, we'll use a deterministic hash of the user's email for our cache key. this should make the chance of a collision if no dedicated store is used statistically insignificant. I've also opted to extract out a `makeCacheKey()` method here mainly to reduce the duplicated code and help prevent bugs from divergence. however, this could possibly help userland override the cache key generation. maybe I'm overthinking that, maybe it's honestly not a problem. * formatting --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
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.
if a user does not decide to use a dedicated cache store for their password resets, there's a risk of collision/overwriting of the cache keys in the default cache store, since we are just using the user's email. this allows the user to set an optional config value to use a prefix on the cache key.
I left the default blank to start, but we could also choose to come up with some default string.
the other option to this PR is to force people to use a dedicated cache store, which I think we should at least strongly encourage for other reasons as well.