Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
LC_server_goods
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0645735f
authored
Dec 05, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改redis前缀以及品牌直接读取缓存
parent
dc2ad983
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
18 deletions
.env
app/Model/SelfBrandModel.php
config/database.php
.env
View file @
0645735f
...
...
@@ -63,6 +63,7 @@ DB_PREFIX=lie_
REDIS_HOST=192.168.1.235
REDIS_PASSWORD=icDb29mLy2s
REDIS_PORT=6379
REDIS_PREFIX=LC_
REDIS_READ_HOST=192.168.1.237
REDIS_READ_PASSWORD=icDb29mLy2s
...
...
app/Model/SelfBrandModel.php
View file @
0645735f
...
...
@@ -61,24 +61,28 @@ class SelfBrandModel extends Model
{
$expireMinutes
=
5
;
return
Cache
::
remember
(
'brandList_'
.
json_encode
(
$map
),
$expireMinutes
,
function
()
use
(
$map
)
{
$field
=
[
'brand_id'
,
'brand_name'
,
'brand_logo'
,
'create_time'
,
'brand_area'
,
'brand_brief'
,
];
//先去缓存里面取
$Redis
=
new
RedisModel
;
$brandList
=
$Redis
->
hgetall
(
'Self_Brand'
);
if
(
!
$brandList
)
{
return
Cache
::
remember
(
'brandList_'
.
json_encode
(
$map
),
$expireMinutes
,
function
()
use
(
$map
)
{
$field
=
[
'brand_id'
,
'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'
]))
{
$areaIds
=
explode
(
','
,
$map
[
'brand_area'
]);
$query
->
whereIn
(
'brand_area'
,
$areaIds
);
}
return
$query
->
get
()
->
toArray
();
});
}
return
$query
->
get
()
->
toArray
();
});
return
$brandList
;
}
}
config/database.php
View file @
0645735f
...
...
@@ -343,8 +343,10 @@ return [
*/
'redis'
=>
[
'cluster'
=>
env
(
'REDIS_CLUSTER'
,
false
),
'options'
=>
[
'cluster'
=>
env
(
'REDIS_CLUSTER'
,
false
),
'prefix'
=>
env
(
'REDIS_PREFIX'
),
],
'default'
=>
[
'host'
=>
env
(
'REDIS_HOST'
,
'127.0.0.1'
),
'password'
=>
env
(
'REDIS_PASSWORD'
,
null
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment