<?php
$patterns=array(
‘foo:.+’,
‘bar:.+’,
‘.+’,
);
$redis=new Redis();
$redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY);
$result=array_fill_keys($patterns, 0);
while ($keys=$redis->scan($it, $match=’*’, $count=1000)) {
foreach ($keys as $key) {
foreach ($patterns as $pattern) {
if (preg_match(“/^{$pattern}$/”, $key)) {
if ($v=$redis->debug($key)) {
$result[$pattern] +=$v[‘serializedlength’];
}
break;
}
}
}
}
var_dump($result);
?>
© 版权声明
文章版权归作者所有,未经允许请勿转载。