[8.x] Fix possible out of memory error when deleting values by reference key from cache in Redis driver #40039
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.
This PR solves possible out of memory issue when deleting values by reference key from cache in Redis driver. PR contains changes from #39939, but also takes into consideration that Laravel supports 2 Redis clients: phpredis and predis (issue #40037).
Changes from the PR #39939:
In case of empty results of
sscan
command predis client returns default cursor value and empty array. At the same time phpredis just returnsfalse
.To process this I suggest break the loop if
$valuesChunk
isnull
. Because array destruction onfalse
writesnull
to all array items.phpredis returns integer values as cursor. So we should cast
$cursor
to string to make a correct comparison with a default value.Options for
sscan
command are in lowercase to work correct with both Redis clients. Otherwise phpredis processes set by 10 items per iteration