|
|
@@ -15,12 +15,12 @@ use Yii;
|
|
|
*/
|
|
|
class HomePageModuleClass
|
|
|
{
|
|
|
- const REDIS_NAV_GRID = '_home_page_config_nav_grid';
|
|
|
- const REDIS_SECKILL = '_home_page_config_seckill';
|
|
|
- const REDIS_GROUP_BUY = '_home_page_config_group_buy';
|
|
|
- const REDIS_HOT = '_home_page_config_hot';
|
|
|
- const REDIS_NEW = '_home_page_config_new';
|
|
|
- const REDIS_PULL_GOODS = '_home_page_config_pull_goods';
|
|
|
+ const REDIS_NAV_GRID = 'home_page_config:%d:nav_grid';
|
|
|
+ const REDIS_SECKILL = 'home_page_config:%d:seckill';
|
|
|
+ const REDIS_GROUP_BUY = 'home_page_config:%d:group_buy';
|
|
|
+ const REDIS_HOT = 'home_page_config:%d:hot';
|
|
|
+ const REDIS_NEW = 'home_page_config:%d:new';
|
|
|
+ const REDIS_PULL_GOODS = 'home_page_config:%d:pull_goods';
|
|
|
|
|
|
const NAV_OSS_ROOT = 'uploads_home_nav';
|
|
|
const MAX_NAV_COUNT = 20;
|
|
|
@@ -46,14 +46,15 @@ class HomePageModuleClass
|
|
|
/** 首页展示商品解析默认条数上限 */
|
|
|
const DISPLAY_GOODS_LIMIT = 20;
|
|
|
|
|
|
- public static function redisKey($mainId, $suffix)
|
|
|
+ public static function redisKey($mainId, $str)
|
|
|
{
|
|
|
- return intval($mainId) . $suffix;
|
|
|
+ return sprintf($str, $mainId);
|
|
|
+ //return $str . intval($mainId);
|
|
|
}
|
|
|
|
|
|
- public static function getJson($mainId, $suffix)
|
|
|
+ public static function getJson($mainId, $str)
|
|
|
{
|
|
|
- $raw = Yii::$app->redis->executeCommand('GET', [self::redisKey($mainId, $suffix)]);
|
|
|
+ $raw = Yii::$app->redis->executeCommand('GET', [self::redisKey($mainId, $str)]);
|
|
|
if (empty($raw)) {
|
|
|
return [];
|
|
|
}
|
|
|
@@ -61,10 +62,10 @@ class HomePageModuleClass
|
|
|
return is_array($data) ? $data : [];
|
|
|
}
|
|
|
|
|
|
- public static function setJson($mainId, $suffix, $payload)
|
|
|
+ public static function setJson($mainId, $str, $payload)
|
|
|
{
|
|
|
Yii::$app->redis->executeCommand('SET', [
|
|
|
- self::redisKey($mainId, $suffix),
|
|
|
+ self::redisKey($mainId, $str),
|
|
|
json_encode($payload, JSON_UNESCAPED_UNICODE),
|
|
|
]);
|
|
|
}
|