mirror of
https://github.com/friendica/friendica
synced 2025-04-23 05:10:11 +00:00
friendica-5847 Console Cache List command doesn't work
- Added $prefix to all CacheDriver - Moved hostname magic to CacheDriver - Added test for getAllKeys()
This commit is contained in:
parent
1551570b7f
commit
3f0f3b6ae6
15 changed files with 131 additions and 48 deletions
|
@ -16,11 +16,23 @@ class DatabaseCacheDriver extends AbstractCacheDriver implements ICacheDriver
|
|||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function getAllKeys()
|
||||
public function getAllKeys($prefix = null)
|
||||
{
|
||||
$stmt = DBA::select('cache', ['k'], ['`expires` >= ?', DateTimeFormat::utcNow()]);
|
||||
if (empty($prefix)) {
|
||||
$where = ['`expires` >= ?', DateTimeFormat::utcNow()];
|
||||
} else {
|
||||
$where = ['`expires` >= ? AND k LIKE CONCAT(?, \'%\')', DateTimeFormat::utcNow(), $prefix];
|
||||
}
|
||||
|
||||
return DBA::toArray($stmt);
|
||||
$stmt = DBA::select('cache', ['k'], $where);
|
||||
|
||||
$list = [];
|
||||
while ($key = DBA::fetch($stmt)) {
|
||||
array_push($list, $key['k']);
|
||||
}
|
||||
DBA::close($stmt);
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue