feat: redis

This commit is contained in:
2025-01-21 16:20:16 +08:00
parent df78fc705d
commit 2beb8d9e55
32 changed files with 310 additions and 84 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Cache\Redis\Admin;
use App\Cache\Redis\RedisCache;
use App\Constants\RedisCode;
use App\Model\AdminSection;
use App\Service\ServiceTrait\Admin\SectionTrait;
use Hyperf\Di\Annotation\Inject;
@@ -49,15 +50,15 @@ class SectionCache
*/
public function getList(): array
{
if ($this->redis->exists($this->key,'system')) {
return json_decode($this->redis->get($this->key,'system'),true);
if ($this->redis->exists($this->key,RedisCode::SYSTEM_DB)) {
return json_decode($this->redis->get($this->key,RedisCode::SYSTEM_DB),true);
}
$allList = $this->adminSectionModel->getList();
$data = $this->getDbList($allList);
$this->redis->set($this->key,json_encode($data),'system');
$this->redis->set($this->key,json_encode($data),RedisCode::SYSTEM_DB);
return $data;
}
@@ -70,6 +71,6 @@ class SectionCache
*/
public function delList()
{
$this->redis->delete($this->key,'system');
$this->redis->delete($this->key,RedisCode::SYSTEM_DB);
}
}