fix : readme update

This commit is contained in:
2025-09-17 17:18:18 +08:00
parent 082c15d697
commit 5d2f32b22b
6 changed files with 224 additions and 36 deletions

View File

@@ -163,7 +163,7 @@ abstract class BaseScript
];
$logStrategy = match(true) {
!$success => $this->logger->cache()->error(...),
!$success => $this->logger->error()->error(...),
$this->debugMode => $this->logger->cache()->debug(...),
default => fn() => null // 不记录
};

View File

@@ -2,6 +2,7 @@
namespace App\Cache\Redis;
use App\Cache\Redis\Lua\RateLimit;
use App\Lib\Log\Logger;
use Hyperf\Contract\ConfigInterface;
use Hyperf\Redis\RedisFactory;
@@ -9,6 +10,7 @@ use Hyperf\Redis\RedisProxy;
/**
* @mixin RedisProxy
* @template T
*/
class RedisCache
{
@@ -53,10 +55,11 @@ class RedisCache
}
/**
* @param string $scriptClass
* @return mixed
* @template TReturn
* @param class-string<TReturn> $scriptClass
* @return TReturn
*/
public function lua(string $scriptClass): mixed
public function lua(string $scriptClass)
{
$poolName = $this->poolName ?? 'default';
$key = $poolName . ':' . $scriptClass;

View File

@@ -2,6 +2,7 @@
namespace App\Common\Trait;
use App\Cache\Redis\Lua\RateLimit;
use App\Cache\Redis\RedisCache;
use App\Cache\Redis\RedisKey;
use App\Common\Repository\AdminUserRepository;
@@ -34,7 +35,7 @@ trait AdminUserTrait
if (Context::has($key)) {
return Context::get($key,false);
}
$this->redis->with()->lua(RateLimit::class)->check();
if ($this->redis->with()->exists($key)) {
$userInfo = unserialize($this->redis->with()->get($key));
Context::set($key,$userInfo);