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\Common;
use App\Cache\Redis\RedisCache;
use App\Constants\RedisCode;
use App\Model\Cycle;
use Hyperf\Di\Annotation\Inject;
use Psr\Container\ContainerExceptionInterface;
@@ -10,6 +11,7 @@ use Psr\Container\NotFoundExceptionInterface;
class CycleCache
{
/**
* @var RedisCache
*/
@@ -31,7 +33,7 @@ class CycleCache
{
$key = CommonRedisKey::getCycleList();
if ($this->redis->exists($key,'system')) return;
if ($this->redis->exists($key,RedisCode::SYSTEM_DB)) return;
$allData = $this->cycleModel->get();
@@ -40,7 +42,12 @@ class CycleCache
$allData = $allData->toArray();
foreach ($allData as $item) {
$this->redis->zAdd($key, $item['id'],$item['dates'],'system');
$this->redis->zAdd($key, $item['id'],$item['dates'],RedisCode::SYSTEM_DB);
}
}
// public function getCycleCache(string $key)
// {
// $this->redis->zScore()
// }
}