Bugfixings for getAllKeys()
This commit is contained in:
parent
8491f8660f
commit
7da6da6666
|
@ -53,7 +53,7 @@ class Cache extends \Friendica\BaseObject
|
|||
*
|
||||
* @param string $prefix Prefix of the keys (optional)
|
||||
*
|
||||
* @return array|null Null if the driver doesn't support this feature
|
||||
* @return array Empty if the driver doesn't support this feature
|
||||
*/
|
||||
public static function getAllKeys($prefix = null)
|
||||
{
|
||||
|
|
|
@ -21,18 +21,18 @@ class DatabaseCacheDriver extends AbstractCacheDriver implements ICacheDriver
|
|||
if (empty($prefix)) {
|
||||
$where = ['`expires` >= ?', DateTimeFormat::utcNow()];
|
||||
} else {
|
||||
$where = ['`expires` >= ? AND k LIKE CONCAT(?, \'%\')', DateTimeFormat::utcNow(), $prefix];
|
||||
$where = ['`expires` >= ? AND `k` LIKE CONCAT(?, \'%\')', DateTimeFormat::utcNow(), $prefix];
|
||||
}
|
||||
|
||||
$stmt = DBA::select('cache', ['k'], $where);
|
||||
|
||||
$list = [];
|
||||
$keys = [];
|
||||
while ($key = DBA::fetch($stmt)) {
|
||||
array_push($list, $key['k']);
|
||||
array_push($keys, $key['k']);
|
||||
}
|
||||
DBA::close($stmt);
|
||||
|
||||
return $list;
|
||||
return $keys;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,7 +16,7 @@ interface ICacheDriver
|
|||
*
|
||||
* @param string prefix optional a prefix to search
|
||||
*
|
||||
* @return array|null Null if it isn't supported by the cache driver
|
||||
* @return array Empty if it isn't supported by the cache driver
|
||||
*/
|
||||
public function getAllKeys($prefix = null);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ class MemcachedCacheDriver extends AbstractCacheDriver implements IMemoryCacheDr
|
|||
return $this->filterArrayKeysByPrefix($keys, $prefix);
|
||||
} else {
|
||||
logger('Memcached \'getAllKeys\' failed with ' . $this->memcached->getResultMessage(), LOGGER_ALL);
|
||||
return null;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,6 +116,7 @@ HELP;
|
|||
$count = 0;
|
||||
foreach ($keys as $key) {
|
||||
$this->out($key);
|
||||
$count++;
|
||||
}
|
||||
|
||||
$this->out($count . ' keys found');
|
||||
|
|
Loading…
Reference in New Issue
Block a user