Laravel redis 正则匹配keys

有时候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"
]
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容