#119599 Модерация. На проде не открывается страница управления кешем
This commit is contained in:
@@ -92,7 +92,13 @@ class RedisCache
|
|||||||
|
|
||||||
public static function hset($key, $field, $value)
|
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)
|
public static function hsetModel($key, $field, $model)
|
||||||
@@ -134,7 +140,7 @@ class RedisCache
|
|||||||
{
|
{
|
||||||
$output = json_decode(Yii::$app->redis->hget($key, $field), true);
|
$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)
|
public static function hgetModel($key, $field, $className)
|
||||||
@@ -230,12 +236,11 @@ class RedisCache
|
|||||||
|
|
||||||
public static function getKeyTypes()
|
public static function getKeyTypes()
|
||||||
{
|
{
|
||||||
|
$result = Yii::$app->redis->keys('types:*');
|
||||||
$result = Yii::$app->redis->keys('*');
|
$output = ['*', 'types'];
|
||||||
$output = ['*'];
|
|
||||||
foreach ($result as $val)
|
foreach ($result as $val)
|
||||||
{
|
{
|
||||||
$arVal = explode(':', $val);
|
$arVal = explode('types:', $val);
|
||||||
if (isset($arVal[1]) && !in_array($arVal[1], $output))
|
if (isset($arVal[1]) && !in_array($arVal[1], $output))
|
||||||
{
|
{
|
||||||
$output[] = $arVal[1];
|
$output[] = $arVal[1];
|
||||||
@@ -278,6 +283,7 @@ class RedisCache
|
|||||||
{
|
{
|
||||||
$options = ['EX' => $options];
|
$options = ['EX' => $options];
|
||||||
}
|
}
|
||||||
|
Yii::$app->redis->set('types:'. explode(':', $key)[0], 1);
|
||||||
Yii::$app->redis->set($key, json_encode($value), $options);
|
Yii::$app->redis->set($key, json_encode($value), $options);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
|
|||||||
Reference in New Issue
Block a user