Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
279ac77f
Commit
279ac77f
authored
Aug 01, 2019
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
批量去除权限规则缓存
parent
f84d7e73
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
4 deletions
+38
-4
RedisCacheService.php
application/api_broker/service/RedisCacheService.php
+14
-4
route.php
application/route.php
+1
-0
UpdateRedisCache.php
application/task/controller/UpdateRedisCache.php
+23
-0
No files found.
application/api_broker/service/RedisCacheService.php
View file @
279ac77f
...
...
@@ -235,8 +235,13 @@ class RedisCacheService
$m_auth_rule
=
new
AuthRule
();
$field
=
'id,name,title,pid,is_menu'
;
$data
=
$m_auth_rule
->
getRule
(
$field
,
[
'name'
=>
$name
,
'status'
=>
0
]);
$this
->
setRedisCache
(
$this
->
rule_key
.
$name
,
$data
[
0
]);
$result
=
$data
[
0
];
if
(
!
empty
(
$data
))
{
$this
->
setRedisCache
(
$this
->
rule_key
.
$name
,
$data
[
0
]);
$result
=
$data
[
0
];
}
else
{
$result
=
[];
}
}
catch
(
\Exception
$e
)
{
$result
=
[];
}
...
...
@@ -275,7 +280,10 @@ class RedisCacheService
if
(
empty
(
$result
))
{
$m_auth_rule
=
new
ASite
();
$result
=
$m_auth_rule
->
getSiteList
();
$this
->
setRedisCache
(
$this
->
site_city_all_key
,
$result
);
if
(
!
empty
(
$result
))
{
$this
->
setRedisCache
(
$this
->
site_city_all_key
,
$result
);
}
}
else
{
$result
=
json_decode
(
$result
,
true
);
}
...
...
@@ -294,7 +302,9 @@ class RedisCacheService
if
(
empty
(
$label_data
))
{
$m_label
=
new
ULabels
();
$label_data
=
$m_label
->
getColumn
(
'id,name'
,
[
'type'
=>
1
]);
//获取标签
$this
->
setRedisCache
(
$this
->
label_call_key
,
$label_data
);
if
(
!
empty
(
$label_data
))
{
$this
->
setRedisCache
(
$this
->
label_call_key
,
$label_data
);
}
}
else
{
$label_data
=
json_decode
(
$label_data
,
true
);
}
...
...
application/route.php
View file @
279ac77f
...
...
@@ -766,6 +766,7 @@ Route::group('task', [
'delAgent'
=>
[
'task/UpdateRedisCache/delAgent'
,
[
'method'
=>
'get'
]],
//清空经纪人缓存
'delCache'
=>
[
'task/UpdateRedisCache/delCache'
,
[
'method'
=>
'get'
]],
//清空多种缓存
'delGroup'
=>
[
'task/UpdateRedisCache/delGroup'
,
[
'method'
=>
'get'
]],
//批量去除角色缓存
'delRule'
=>
[
'task/UpdateRedisCache/delRule'
,
[
'method'
=>
'get'
]],
//批量去除规则缓存
]);
Route
::
group
(
'broker'
,
[
...
...
application/task/controller/UpdateRedisCache.php
View file @
279ac77f
...
...
@@ -12,6 +12,7 @@ namespace app\task\controller;
use
app\api_broker\service\RedisCacheService
;
use
app\model\AAgents
;
use
app\model\AuthGroup
;
use
app\model\AuthRule
;
use
think\Request
;
class
UpdateRedisCache
...
...
@@ -63,4 +64,25 @@ class UpdateRedisCache
}
}
/**
* 批量去除权限规则缓存
*
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
delRule
()
{
$m_rule
=
new
AuthRule
();
$rule_data
=
$m_rule
->
getRule
(
'name'
,
[]);
$num
=
0
;
foreach
(
$rule_data
as
$v
)
{
$is_del
=
$this
->
redis_service
->
delRedisCache
(
4
,
$v
[
'name'
]);
if
(
$is_del
)
{
$num
++
;
}
}
echo
$num
;
}
}
\ No newline at end of file
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