1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-03-15 11:50:01 +01:00

Update filter for Redis

Make filter work with multiple keys and wildcard search, eg. user/* or ip 10.0.*
This commit is contained in:
Barry vd. Heuvel 2014-01-14 09:54:06 +01:00
parent 1663f3808b
commit 8d00a2ac74

View File

@ -55,13 +55,22 @@ class RedisStorage implements StorageInterface
foreach ($this->redis->hgetall($this->hash) as $id => $data) {
if ($data = unserialize($data)) {
$meta = $data['__meta'];
if (array_keys(array_intersect($meta, $filters)) == array_keys($filters)) {
if ($this->filter($meta, $filters)) {
$results[] = $meta;
}
}
}
return array_slice($results, $offset, $max);
}
protected function filter($meta, $filters){
foreach($filters as $key => $value){
if(fnmatch ($value, $meta[$key]) === false){
return false;
}
}
return true;
}
/**
* {@inheritDoc}
@ -70,4 +79,4 @@ class RedisStorage implements StorageInterface
{
$this->redis->del($this->hash);
}
}
}