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

@@ -2,7 +2,9 @@
namespace App\Service\ServiceTrait\Common;
use App\Cache\Redis\Common\ConfigCache;
use App\Cache\Redis\Common\CycleCache;
use App\Constants\ConfigCode;
use Hyperf\Di\Annotation\Inject;
trait CycleTrait
@@ -13,10 +15,22 @@ trait CycleTrait
#[Inject]
protected CycleCache $cycleCache;
/**
* @var ConfigCache
*/
#[Inject]
protected ConfigCache $configCache;
protected function initTodayCycleId()
{
$TodayCutOffTime = $this->configCache->getConfigValueByKey(ConfigCode::TODAY_CUT_OFF_TIME_KEY);
if (date('H:i:s') >= ($TodayCutOffTime)) {
$day = date('Y-m-d',strtotime('+1 day'));
} else {
$day = date('Y-m-d',strtotime('today'));
}
}
}

View File

@@ -12,6 +12,7 @@ namespace App\Service\ServiceTrait\Common;
use App\Cache\Redis\Common\CommonRedisKey;
use App\Cache\Redis\RedisCache;
use App\Constants\RedisCode;
use Hyperf\Di\Annotation\Inject;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
@@ -36,7 +37,7 @@ trait SiteTrait
public function setSiteCache($value, string $lng = '0', string $lat = '0'): void
{
$key = CommonRedisKey::getActivateSiteList();
$this->redisCache->zRem($key,$value,'system');
$this->redisCache->geoAdd($key,$lng,$lat,$value,'system');
$this->redisCache->zRem($key,$value,RedisCode::SYSTEM_DB);
$this->redisCache->geoAdd($key,$lng,$lat,$value,RedisCode::SYSTEM_DB);
}
}