feat: spu
This commit is contained in:
@@ -48,4 +48,12 @@ class CommonRedisKey
|
||||
{
|
||||
return '__system:wx:AccessToken:';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getCycleList(): string
|
||||
{
|
||||
return '__cycle:list';
|
||||
}
|
||||
}
|
||||
46
app/Cache/Redis/Common/CycleCache.php
Normal file
46
app/Cache/Redis/Common/CycleCache.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Cache\Redis\Common;
|
||||
|
||||
use App\Cache\Redis\RedisCache;
|
||||
use App\Model\Cycle;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
class CycleCache
|
||||
{
|
||||
/**
|
||||
* @var RedisCache
|
||||
*/
|
||||
#[Inject]
|
||||
protected RedisCache $redis;
|
||||
|
||||
/**
|
||||
* @var Cycle $cycleModel
|
||||
*/
|
||||
#[Inject]
|
||||
protected Cycle $cycleModel;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function setAllCycleCache(): void
|
||||
{
|
||||
$key = CommonRedisKey::getCycleList();
|
||||
|
||||
if ($this->redis->exists($key,'system')) return;
|
||||
|
||||
$allData = $this->cycleModel->get();
|
||||
|
||||
if (empty($allData)) return;
|
||||
|
||||
$allData = $allData->toArray();
|
||||
|
||||
foreach ($allData as $item) {
|
||||
$this->redis->zAdd($key, $item['id'],$item['dates'],'system');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -540,6 +540,19 @@ class RedisCache
|
||||
{
|
||||
return $this->getRedis($poolName)->zRem($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @param $value
|
||||
* @param string $poolName
|
||||
* @return false|int|Redis
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function zRank($key, $value, string $poolName = 'default')
|
||||
{
|
||||
return $this->getRedis($poolName)->zRank($key, $value);
|
||||
}
|
||||
// +--------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// | geo
|
||||
// +--------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user