From 9ccaf4ab1127cc7594ce7d76862f6dfd303c04e8 Mon Sep 17 00:00:00 2001 From: Sasha Rybkin Date: Thu, 20 Nov 2025 14:58:18 +0300 Subject: [PATCH] =?UTF-8?q?#119599=20=D0=9C=D0=BE=D0=B4=D0=B5=D1=80=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F.=20=D0=9D=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B4?= =?UTF-8?q?=D0=B5=20=D0=BD=D0=B5=20=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D0=B2?= =?UTF-8?q?=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20=D1=81=D1=82=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=86=D0=B0=20=D1=83=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=BA=D0=B5=D1=88=D0=B5=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RedisCache.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/RedisCache.php b/RedisCache.php index 301005a..4785f90 100644 --- a/RedisCache.php +++ b/RedisCache.php @@ -92,7 +92,13 @@ class RedisCache public static function hset($key, $field, $value) { - return self::getActive() ? Yii::$app->redis->hset($key, $field, json_encode($value)) : false; + $output = false; + if(self::getActive()) + { + Yii::$app->redis->set('types:'.explode(':', $key)[0], 1); + $output = Yii::$app->redis->hset($key, $field, json_encode($value)); + } + return $output; } public static function hsetModel($key, $field, $model) @@ -134,7 +140,7 @@ class RedisCache { $output = json_decode(Yii::$app->redis->hget($key, $field), true); } - return $output === null ? false : $output;; + return $output === null ? false : $output; } public static function hgetModel($key, $field, $className) @@ -230,12 +236,11 @@ class RedisCache public static function getKeyTypes() { - - $result = Yii::$app->redis->keys('*'); - $output = ['*']; + $result = Yii::$app->redis->keys('types:*'); + $output = ['*', 'types']; foreach ($result as $val) { - $arVal = explode(':', $val); + $arVal = explode('types:', $val); if (isset($arVal[1]) && !in_array($arVal[1], $output)) { $output[] = $arVal[1]; @@ -278,6 +283,7 @@ class RedisCache { $options = ['EX' => $options]; } + Yii::$app->redis->set('types:'. explode(':', $key)[0], 1); Yii::$app->redis->set($key, json_encode($value), $options); } return $result;