From b0b785bcb06bd8115c0de173c17de9f753882df2 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 8 Dec 2019 08:32:11 +0100 Subject: [PATCH] apparently redis doesn't even have int/float values --- DataStorage/Cache/Connection/RedisCache.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/DataStorage/Cache/Connection/RedisCache.php b/DataStorage/Cache/Connection/RedisCache.php index 6e62b3563..48639f99f 100644 --- a/DataStorage/Cache/Connection/RedisCache.php +++ b/DataStorage/Cache/Connection/RedisCache.php @@ -276,10 +276,8 @@ class RedisCache extends ConnectionAbstract */ private function cachify($value, int $type) { - if (\is_float($value) || \is_int($value) || \is_string($value)) { - return $value; - } elseif ($type === CacheValueType::_BOOL) { - return (string) ((int) $value); + if ($type === CacheValueType::_INT || $type === CacheValueType::_STRING || $type === CacheValueType::_BOOL) { + return (string) $value; } elseif ($type === CacheValueType::_ARRAY) { return (string) \json_encode($value); } elseif ($type === CacheValueType::_SERIALIZABLE) { @@ -306,11 +304,11 @@ class RedisCache extends ConnectionAbstract */ private function reverseValue(int $type, $raw, int $start) { - if ($type === \is_int($raw) || $type === \is_float($raw)) { - return $raw; - } - switch ($type) { + case CacheValueType::_INT: + return (int) \substr($raw, $expireEnd + 1); + case CacheValueType::_FLOAT: + return (float) \substr($raw, $expireEnd + 1); case CacheValueType::_BOOL: return (bool) \substr($raw, $start + 1); case CacheValueType::_STRING: