Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
semour
/
semour_web
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
d810333f
authored
Dec 05, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
分类加上缓存
parent
1d86301f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletions
app/Http/Services/ClassService.php
app/Http/Services/ClassService.php
View file @
d810333f
...
...
@@ -9,6 +9,10 @@ class ClassService
//获取首页需要的所有分类,没有英文名称的不要
public
static
function
getClassificationForHome
()
{
$cache
=
Redis
::
get
(
'semour_classification_cache'
);
if
(
$cache
)
{
return
json_decode
(
$cache
,
true
);
}
//先获取所有分类
$classData
=
\Http
::
get
(
config
(
'website.footstone_url'
)
.
'/open/getClassification'
)
->
json
();
$secondClassList
=
[];
...
...
@@ -56,13 +60,20 @@ class ClassService
}
}
}
return
array_values
(
$topFields
);
$data
=
array_values
(
$topFields
);
Redis
::
set
(
'semour_classification_cache'
,
json_encode
(
$data
));
Redis
::
expire
(
'semour_classification_cache'
,
600
);
return
$data
;
}
return
[];
}
public
static
function
getClassificationById
(
$classId
,
$includeChildren
=
false
)
{
$cache
=
Redis
::
get
(
'semour_classification_cache_'
.
$classId
);
if
(
$cache
)
{
return
json_decode
(
$cache
,
true
);
}
$classData
=
\Http
::
get
(
config
(
'website.footstone_url'
)
.
'/open/getClassification'
)
->
json
();
if
(
isset
(
$classData
[
'code'
])
&&
$classData
[
'code'
]
==
0
)
{
$classificationCache
=
$classData
[
'data'
];
...
...
@@ -87,6 +98,8 @@ class ClassService
}
}
$classification
[
'sku_number'
]
=
$totalSkuNumber
;
Redis
::
set
(
'semour_classification_cache_'
.
$classId
,
json_encode
(
$classification
));
Redis
::
expire
(
'semour_classification_cache_'
.
$classId
,
600
);
return
$classification
;
}
return
[];
...
...
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