]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Cache/DatabaseCacheDriver.php
Merge branch 'develop' of https://github.com/friendica/friendica into develop
[friendica.git] / src / Core / Cache / DatabaseCacheDriver.php
index 74dfe3991e1ca4beeb818db1bf23f885a5903cb7..d90c6e4f18180f6777a316dbe1cf2d70249ce85f 100644 (file)
@@ -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];
+               }
+
+               $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;
        }
 
        /**