@@ -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