feat : check

This commit is contained in:
2025-04-02 10:00:54 +08:00
parent e39d7a724b
commit 4276021041
3 changed files with 16 additions and 8 deletions

View File

@@ -53,7 +53,7 @@ class PrinterCache
private function __initPrinterListData(): void
{
$printerList = $this->printerModel->get();
var_dump($printerList->isEmpty());
if ($printerList->isEmpty()) return;
$ylyPrinterList = [];
@@ -67,8 +67,8 @@ class PrinterCache
$this->delCache();
$this->redisCache->set($this->ylyPrinterKey, json_encode($ylyPrinterList));
$this->redisCache->set($this->jdPrinterKey, json_encode($jdPrinterList));
$this->redisCache->set($this->ylyPrinterKey, json_encode($ylyPrinterList),RedisCode::SYSTEM_DB);
$this->redisCache->set($this->jdPrinterKey, json_encode($jdPrinterList),RedisCode::SYSTEM_DB);
}
/**
@@ -78,7 +78,7 @@ class PrinterCache
*/
public function getYlyPrinter(): array
{
if ($this->redisCache->exists($this->ylyPrinterKey,RedisCode::SYSTEM_DB)) $this->__initPrinterListData();
if (!$this->redisCache->exists($this->ylyPrinterKey,RedisCode::SYSTEM_DB)) $this->__initPrinterListData();
$res = $this->redisCache->get($this->ylyPrinterKey, RedisCode::SYSTEM_DB);
if (empty($res)) return [];
@@ -92,7 +92,7 @@ class PrinterCache
*/
public function getOtherPrinter(): array
{
if ($this->redisCache->exists($this->jdPrinterKey,RedisCode::SYSTEM_DB)) $this->__initPrinterListData();
if (!$this->redisCache->exists($this->jdPrinterKey,RedisCode::SYSTEM_DB)) $this->__initPrinterListData();
$res = $this->redisCache->get($this->jdPrinterKey, RedisCode::SYSTEM_DB);
if (empty($res)) return [];
@@ -106,7 +106,7 @@ class PrinterCache
*/
public function delCache(): void
{
$this->redisCache->delete($this->ylyPrinterKey);
$this->redisCache->delete($this->jdPrinterKey);
$this->redisCache->delete($this->ylyPrinterKey,RedisCode::SYSTEM_DB);
$this->redisCache->delete($this->jdPrinterKey,RedisCode::SYSTEM_DB);
}
}