有時候redis 需要正則匹配到相應的keys, 然後獲取keys列表
通用使用command 命令執行keys命令匹配到相應的key
$redis = \Illuminate\Support\Facades\Redis::connection('default');
$result = $redis->command('KEYS', ['Test:hello:*']);
dd($result);
執行結果
array:8 [
0 => "Test:hello:1"
1 => "Test:hello:2"
2 => "Test:hello:3"
3 => "Test:hello:4"
4 => "Test:hello:5"
5 => "Test:hello:6"
6 => "Test:hello:7"
7 => "Test:hello:8"
]
本作品採用《CC 協議》,轉載必須註明作者和本文連結