feat: redis
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Cache\Redis\Admin;
|
||||
use App\Cache\Redis\RedisCache;
|
||||
use App\Constants\Admin\AuthCode;
|
||||
use App\Constants\Common\RoleCode;
|
||||
use App\Constants\RedisCode;
|
||||
use App\Model\AdminMenu;
|
||||
use App\Model\AdminRoleMenu;
|
||||
use App\Service\ServiceTrait\Admin\AdminRoleMenuTrait;
|
||||
@@ -75,10 +76,10 @@ class RoleCache
|
||||
|
||||
$this->getKey();
|
||||
|
||||
if ($this->redis->exists($this->roleMenuArrKey,'system') && $this->redis->exists($this->roleMenuListKey,'system')) {
|
||||
if ($this->redis->exists($this->roleMenuArrKey,RedisCode::SYSTEM_DB) && $this->redis->exists($this->roleMenuListKey,RedisCode::SYSTEM_DB)) {
|
||||
return [
|
||||
'role_arr' => $this->redis->sMembers($this->roleMenuArrKey,'system'),
|
||||
'role_list' => json_decode($this->redis->get($this->roleMenuListKey,'system'),true),
|
||||
'role_arr' => $this->redis->sMembers($this->roleMenuArrKey,RedisCode::SYSTEM_DB),
|
||||
'role_list' => json_decode($this->redis->get($this->roleMenuListKey,RedisCode::SYSTEM_DB),true),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -101,8 +102,8 @@ class RoleCache
|
||||
|
||||
$this->delRoleCache();
|
||||
|
||||
$this->redis->set($this->roleMenuListKey,json_encode($data),'system');
|
||||
$this->redis->sAddBatch($this->roleMenuArrKey,$menuIds,'system');
|
||||
$this->redis->set($this->roleMenuListKey,json_encode($data),RedisCode::SYSTEM_DB);
|
||||
$this->redis->sAddBatch($this->roleMenuArrKey,$menuIds,RedisCode::SYSTEM_DB);
|
||||
|
||||
return [
|
||||
'role_arr' => $menuIds,
|
||||
@@ -124,7 +125,7 @@ class RoleCache
|
||||
$this->getKey();
|
||||
}
|
||||
|
||||
$this->redis->delete($this->roleMenuArrKey,'system');
|
||||
$this->redis->delete($this->roleMenuListKey,'system');
|
||||
$this->redis->delete($this->roleMenuArrKey,RedisCode::SYSTEM_DB);
|
||||
$this->redis->delete($this->roleMenuListKey,RedisCode::SYSTEM_DB);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user