mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 11:22:10 +08:00
feat : common redis cache
This commit is contained in:
@@ -5,9 +5,8 @@ namespace App\Cache\Redis;
|
||||
|
||||
use App\Lib\Log\Logger;
|
||||
use Hyperf\Contract\ConfigInterface;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\Redis\Redis;
|
||||
use Swoole\Coroutine;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
abstract class BaseScript
|
||||
@@ -74,7 +73,7 @@ abstract class BaseScript
|
||||
$script = $this->getScriptContent();
|
||||
// $this->logExecution($keys, $args, true);
|
||||
return $this->execute($script, $keys, $args, $numKeys);
|
||||
} catch (Throwable $e) {
|
||||
} catch (Exception|Throwable $e) {
|
||||
$this->logExecution($keys, $args, false, $e);
|
||||
return false;
|
||||
}
|
||||
@@ -82,16 +81,17 @@ abstract class BaseScript
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function getScriptContent(): string
|
||||
{
|
||||
// $path = __DIR__.'/Script/'.$this->getName().'.lua';
|
||||
$path = __DIR__.'/Lua/'.$this->getName().'.lua';
|
||||
$path = __DIR__.'/Script/'.$this->getName().'.lua';
|
||||
// $path = __DIR__.'/Lua/'.$this->getName().'.lua';
|
||||
|
||||
if (!file_exists($path)) echo 1;
|
||||
if (!file_exists($path)) throw new Exception('lua文件不存在');
|
||||
|
||||
$content = file_get_contents($path);
|
||||
if ($content === false) echo 2;
|
||||
if ($content === false) throw new Exception('lua文件读取失败');
|
||||
|
||||
return $content;
|
||||
}
|
||||
@@ -157,7 +157,9 @@ abstract class BaseScript
|
||||
'keys' => $keys,
|
||||
'args' => $args,
|
||||
'success' => $success,
|
||||
'error' => $e?->getMessage()
|
||||
'error' => $e?->getMessage(),
|
||||
'line' => $e?->getLine(),
|
||||
'trace' => $e?->getTraceAsString()
|
||||
];
|
||||
|
||||
$logStrategy = match(true) {
|
||||
|
||||
Reference in New Issue
Block a user