From 7ba9106712ac14de5c4eb8a075884cf9b1c05670 Mon Sep 17 00:00:00 2001 From: ctexthuang Date: Wed, 25 Dec 2024 17:52:30 +0800 Subject: [PATCH] fix : redis multi --- app/Cache/Redis/RedisCache.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/Cache/Redis/RedisCache.php b/app/Cache/Redis/RedisCache.php index 60508ea..488fdf7 100644 --- a/app/Cache/Redis/RedisCache.php +++ b/app/Cache/Redis/RedisCache.php @@ -83,6 +83,29 @@ class RedisCache return $this->delete($key, $poolName); } + /** + * 接下来的操作启用原子操作 - 事物开启 + * @param string $poolName + * @return bool|Redis + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function multi(string $poolName = 'default'): bool|Redis + { + return $this->getRedis($poolName)->multi(); + } + + /** + * 结束原子操作 - 事物结束 + * @param string $poolName + * @return Redis|array|false + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function exec(string$poolName = 'default'): Redis|array|false + { + return $this->getRedis($poolName)->exec(); + } // +-------------------------------------------------------------------------------------------------------------------------------------------- // | key