Skip to content

Commit 01116c9

Browse files
author
shawn.zheng
committed
清除token修改
1 parent d44683f commit 01116c9

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/RedisHandler.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ class RedisHandler
2929
public static function generateToken(string $pre, string $client, string $uid, int $ttl, string $token): void
3030
{
3131
$cacheKey = $pre . $client. ':'. $uid;
32-
$key = Redis::keys($cacheKey . '*');
33-
if (!empty($key)) {
34-
Redis::del(current($key));
35-
}
32+
Redis::del($cacheKey);
3633
Redis::setex($cacheKey, $ttl, $token);
3734
}
3835

@@ -49,8 +46,8 @@ public static function generateToken(string $pre, string $client, string $uid, i
4946
public static function refreshToken(string $pre, string $client, string $uid, int $ttl, string $token): void
5047
{
5148
$cacheKey = $pre . $client . ':' . $uid;
52-
$key = Redis::keys($cacheKey . '*');
53-
if (!empty($key)) {
49+
$isExists = Redis::exists($cacheKey);
50+
if ($isExists) {
5451
$ttl = Redis::ttl($cacheKey);
5552
}
5653
Redis::setex($cacheKey, $ttl, $token);
@@ -87,10 +84,7 @@ public static function verifyToken(string $pre, string $client, string $uid, str
8784
*/
8885
public static function clearToken(string $pre, string $client, string $uid): bool
8986
{
90-
$token = Redis::keys($pre . $client. ':'. $uid);
91-
if ($token) {
92-
Redis::del(current($token));
93-
}
87+
Redis::del($pre . $client. ':'. $uid);
9488
return true;
9589
}
9690
}

0 commit comments

Comments
 (0)