apparently redis doesn't even have int/float values

This commit is contained in:
Dennis Eichhorn 2019-12-08 08:32:11 +01:00
parent 14af04f027
commit b0b785bcb0

View File

@ -276,10 +276,8 @@ class RedisCache extends ConnectionAbstract
*/ */
private function cachify($value, int $type) private function cachify($value, int $type)
{ {
if (\is_float($value) || \is_int($value) || \is_string($value)) { if ($type === CacheValueType::_INT || $type === CacheValueType::_STRING || $type === CacheValueType::_BOOL) {
return $value; return (string) $value;
} elseif ($type === CacheValueType::_BOOL) {
return (string) ((int) $value);
} elseif ($type === CacheValueType::_ARRAY) { } elseif ($type === CacheValueType::_ARRAY) {
return (string) \json_encode($value); return (string) \json_encode($value);
} elseif ($type === CacheValueType::_SERIALIZABLE) { } elseif ($type === CacheValueType::_SERIALIZABLE) {
@ -306,11 +304,11 @@ class RedisCache extends ConnectionAbstract
*/ */
private function reverseValue(int $type, $raw, int $start) private function reverseValue(int $type, $raw, int $start)
{ {
if ($type === \is_int($raw) || $type === \is_float($raw)) {
return $raw;
}
switch ($type) { switch ($type) {
case CacheValueType::_INT:
return (int) \substr($raw, $expireEnd + 1);
case CacheValueType::_FLOAT:
return (float) \substr($raw, $expireEnd + 1);
case CacheValueType::_BOOL: case CacheValueType::_BOOL:
return (bool) \substr($raw, $start + 1); return (bool) \substr($raw, $start + 1);
case CacheValueType::_STRING: case CacheValueType::_STRING: