From c315c9ee3f1a75d8858fd2429e09bab4eb89e0a6 Mon Sep 17 00:00:00 2001 From: weigang Date: Fri, 25 Sep 2020 09:57:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/Implementations/ParamsTokenSsdbService.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/app/Service/v3/Implementations/ParamsTokenSsdbService.php b/app/Service/v3/Implementations/ParamsTokenSsdbService.php index 39850c9..966c9ae 100644 --- a/app/Service/v3/Implementations/ParamsTokenSsdbService.php +++ b/app/Service/v3/Implementations/ParamsTokenSsdbService.php @@ -31,13 +31,7 @@ class ParamsTokenSsdbService implements ParamsTokenServiceInterface $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); - $kvs = []; - foreach ($params as $key => $value) { - $kvs[] = $key; - $kvs[] = $value; - } - - if(false === $ssdb->exec('multi_hset', SsdbKeys::PARAMS_TOKEN.$token, $kvs)) { + if(false === $ssdb->exec('hset', SsdbKeys::PARAMS_TOKEN, $token, json_encode($params))) { throw new ErrorCodeException(ErrorCode::TOKEN_GENERATE_ERROR, 'token生成失败'); } @@ -51,7 +45,7 @@ class ParamsTokenSsdbService implements ParamsTokenServiceInterface public function analyze($token) { $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); - $params = $ssdb->exec('hgetall', SsdbKeys::PARAMS_TOKEN.$token); + $params = $ssdb->exec('hget', SsdbKeys::PARAMS_TOKEN, $token); if (false === $params) { @@ -62,7 +56,7 @@ class ParamsTokenSsdbService implements ParamsTokenServiceInterface throw new ErrorCodeException(ErrorCode::TOKEN_NOT_EXISTS, 'token不存在'); } - return $params; + return json_decode($params, true); } } \ No newline at end of file