Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
formatting
  • Loading branch information
taylorotwell committed Jan 24, 2025
commit e38c18911894cfd3473a368de63cc313c7f60c99
18 changes: 9 additions & 9 deletions src/Illuminate/Cache/RedisStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public function setPrefix($prefix)
protected function pack($value, $connection)
{
if ($connection instanceof PhpRedisConnection) {
if ($this->storePlainValue($value)) {
if ($this->shouldBeStoredWithoutSerialization($value)) {
return $value;
}

Expand All @@ -449,25 +449,25 @@ protected function pack($value, $connection)
}

/**
* Determine if the given value should be stored as plain value or be serialized/compressed instead.
* Serialize the value.
*
* @param mixed $value
* @return bool
* @return mixed
*/
protected function storePlainValue($value): bool
protected function serialize($value)
{
return is_numeric($value) && ! in_array($value, [INF, -INF]) && ! is_nan($value);
return $this->shouldBeStoredWithoutSerialization($value) ? $value : serialize($value);
}

/**
* Serialize the value.
* Determine if the given value should be stored as plain value.
*
* @param mixed $value
* @return mixed
* @return bool
*/
protected function serialize($value)
protected function shouldBeStoredWithoutSerialization($value): bool
{
return $this->storePlainValue($value) ? $value : serialize($value);
return is_numeric($value) && ! in_array($value, [INF, -INF]) && ! is_nan($value);
}

/**
Expand Down