Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
LC_api_news
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
65226667
authored
Nov 28, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
设置缓存
parent
12f4aeec
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
22 deletions
.env
app/Services/FaqService.php
app/Services/NoticeService.php
.env
View file @
65226667
...
...
@@ -25,5 +25,5 @@ REDIS_READ_HOST=192.168.1.235
REDIS_READ_PASSWORD=icDb29mLy2s
REDIS_READ_PORT=6379
CACHE_DRIVER=
file
CACHE_DRIVER=
redis
QUEUE_DRIVER=sync
app/Services/FaqService.php
View file @
65226667
...
...
@@ -6,17 +6,20 @@ namespace App\Services;
use
App\Model\ArctypeModel
;
use
App\Model\ArticleModel
;
use
Illuminate\Support\Facades\Cache
;
class
FaqService
extends
BaseService
{
public
function
getFaqList
()
{
$model
=
new
ArctypeModel
();
//获取所有faq相关的文章,50应该差不多了
$list
=
$model
->
getFaqList
();
$list
=
$this
->
transform
(
$list
);
return
$list
;
return
Cache
::
remember
(
'faqListCache'
,
5
,
function
()
{
$model
=
new
ArctypeModel
();
//获取所有faq相关的文章,50应该差不多了
$list
=
$model
->
getFaqList
();
$list
=
$this
->
transform
(
$list
);
return
$list
;
});
}
...
...
@@ -34,11 +37,13 @@ class FaqService extends BaseService
public
function
getFaq
(
$id
)
{
$model
=
new
ArticleModel
();
$faq
=
$model
->
getFaq
(
$id
);
$faq
=
$this
->
transformFaq
(
$faq
);
return
Cache
::
remember
(
'faqCache_'
.
$id
,
5
,
function
()
use
(
$id
)
{
$model
=
new
ArticleModel
();
$faq
=
$model
->
getFaq
(
$id
);
$faq
=
$this
->
transformFaq
(
$faq
);
return
$faq
;
return
$faq
;
});
}
private
function
transformFaq
(
$data
)
...
...
app/Services/NoticeService.php
View file @
65226667
...
...
@@ -6,17 +6,20 @@ namespace App\Services;
use
App\Model\ArctypeModel
;
use
App\Model\ArticleModel
;
use
Illuminate\Support\Facades\Cache
;
class
NoticeService
extends
BaseService
{
public
function
getNoticeList
(
$page
,
$pageSize
)
public
function
getNoticeList
(
$page
,
$pageSize
)
{
$model
=
new
ArticleModel
();
//获取所有faq相关的文章,50应该差不多了
$list
=
$model
->
getNoticeList
(
$page
,
$pageSize
);
$list
=
$this
->
transform
(
$list
);
return
$list
;
return
Cache
::
remember
(
"noticeListCache_
$page
"
.
"_
$pageSize
"
,
5
,
function
()
use
(
$page
,
$pageSize
)
{
$model
=
new
ArticleModel
();
//获取所有faq相关的文章,50应该差不多了
$list
=
$model
->
getNoticeList
(
$page
,
$pageSize
);
$list
=
$this
->
transform
(
$list
);
return
$list
;
});
}
...
...
@@ -33,11 +36,13 @@ class NoticeService extends BaseService
public
function
getNotice
(
$id
)
{
$model
=
new
ArticleModel
();
$faq
=
$model
->
getNotice
(
$id
);
$faq
=
$this
->
transformNotice
(
$faq
);
return
Cache
::
remember
(
'noticeCache_'
.
$id
,
5
,
function
()
use
(
$id
)
{
$model
=
new
ArticleModel
();
$faq
=
$model
->
getNotice
(
$id
);
$faq
=
$this
->
transformNotice
(
$faq
);
return
$faq
;
return
$faq
;
});
}
private
function
transformNotice
(
$data
)
...
...
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