PHP批量模糊清空Redis

1
2
3
4
5
6
7
8
<?php
$redis = new \Redis();
$redis->connect('127.0.0.1',6379);
$redis->setOption(\Redis::OPT_SCAN, \Redis::SCAN_RETRY);
while ($arr_keys = $redis->scan(NULL, "key_*", 5)) {
call_user_func_array([$redis, 'del'], $arr_keys);
echo var_export($arr_keys, true) . PHP_EOL;
}