Files
hyperf_service/app/Service/ServiceTrait/Common/SiteTrait.php
2024-11-08 16:27:25 +08:00

42 lines
992 B
PHP

<?php
/**
* This service file is part of item.
*
* @author ctexthuang
* @contact ctexthuang@qq.com
*/
declare(strict_types=1);
namespace App\Service\ServiceTrait\Common;
use App\Cache\Redis\Common\CommonRedisKey;
use App\Cache\Redis\RedisCache;
use Hyperf\Di\Annotation\Inject;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
trait SiteTrait
{
/**
* @var RedisCache
*/
#[Inject]
protected RedisCache $redisCache;
/**
* @param $value
* @param string $lng
* @param string $lat
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws \RedisException
*/
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');
}
}