Commit 0645735f by 杨树贤

修改redis前缀以及品牌直接读取缓存

parent dc2ad983
...@@ -63,6 +63,7 @@ DB_PREFIX=lie_ ...@@ -63,6 +63,7 @@ DB_PREFIX=lie_
REDIS_HOST=192.168.1.235 REDIS_HOST=192.168.1.235
REDIS_PASSWORD=icDb29mLy2s REDIS_PASSWORD=icDb29mLy2s
REDIS_PORT=6379 REDIS_PORT=6379
REDIS_PREFIX=LC_
REDIS_READ_HOST=192.168.1.237 REDIS_READ_HOST=192.168.1.237
REDIS_READ_PASSWORD=icDb29mLy2s REDIS_READ_PASSWORD=icDb29mLy2s
......
...@@ -61,24 +61,28 @@ class SelfBrandModel extends Model ...@@ -61,24 +61,28 @@ class SelfBrandModel extends Model
{ {
$expireMinutes = 5; $expireMinutes = 5;
return Cache::remember('brandList_' . json_encode($map), $expireMinutes, function () use ($map) { //先去缓存里面取
$field = [ $Redis = new RedisModel;
'brand_id', $brandList = $Redis->hgetall('Self_Brand');
'brand_name', if (!$brandList) {
'brand_logo', return Cache::remember('brandList_' . json_encode($map), $expireMinutes, function () use ($map) {
'create_time', $field = [
'brand_area', 'brand_id',
'brand_brief', 'brand_name',
]; 'brand_logo',
'brand_area',
];
$query = $this->select($field)->where('status', 1);
$query = $this->select($field)->where('status', 1); if (!empty($map['brand_area'])) {
$areaIds = explode(',', $map['brand_area']);
$query->whereIn('brand_area', $areaIds);
}
if (!empty($map['brand_area'])) { return $query->get()->toArray();
$areaIds = explode(',', $map['brand_area']); });
$query->whereIn('brand_area', $areaIds); }
}
return $query->get()->toArray(); return $brandList;
});
} }
} }
...@@ -343,8 +343,10 @@ return [ ...@@ -343,8 +343,10 @@ return [
*/ */
'redis' => [ 'redis' => [
'options' => [
'cluster' => env('REDIS_CLUSTER', false), 'cluster' => env('REDIS_CLUSTER', false),
'prefix' => env('REDIS_PREFIX'),
],
'default' => [ 'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'), 'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null), 'password' => env('REDIS_PASSWORD', null),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment