/**
* (@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];
+ }
+
+ $stmt = DBA::select('cache', ['k'], $where);
+
+ $keys = [];
+ while ($key = DBA::fetch($stmt)) {
+ array_push($keys, $key['k']);
+ }
+ DBA::close($stmt);
- return DBA::toArray($stmt);
+ return $keys;
}
/**