return self::$driver;
}
+ /**
+ * @brief Returns all the cache keys sorted alphabetically
+ *
+ * @return array|null Null if the driver doesn't support this feature
+ */
+ public static function getAllKeys()
+ {
+ $time = microtime(true);
+
+ $return = self::getDriver()->getAllKeys();
+
+ // Keys are prefixed with the node hostname, let's remove it
+ array_walk($return, function (&$value) {
+ $value = preg_replace('/^' . self::getApp()->get_hostname() . ':/', '', $value);
+ });
+
+ sort($return);
+
+ self::getApp()->save_timestamp($time, 'cache');
+
+ return $return;
+ }
+
/**
* @brief Fetch cached data according to the key
*
/** @var array Array with the cached data */
protected $cachedData = array();
+ /**
+ * (@inheritdoc)
+ */
+ public function getAllKeys()
+ {
+ return array_keys($this->cachedData);
+ }
+
/**
* (@inheritdoc)
*/
*/
class DatabaseCacheDriver extends AbstractCacheDriver implements ICacheDriver
{
+ /**
+ * (@inheritdoc)
+ */
+ public function getAllKeys()
+ {
+ $stmt = DBA::select('cache', ['k'], ['`expires` >= ?', DateTimeFormat::utcNow()]);
+
+ return DBA::toArray($stmt);
+ }
+
/**
* (@inheritdoc)
*/
*/
interface ICacheDriver
{
+ /**
+ * Lists all cache keys
+ *
+ * @return array|null Null if it isn't supported by the cache driver
+ */
+ public function getAllKeys();
+
/**
* Fetches cached data according to the key
*
}
}
+ /**
+ * (@inheritdoc)
+ */
+ public function getAllKeys()
+ {
+ $list = [];
+ $allSlabs = $this->memcache->getExtendedStats('slabs');
+ foreach($allSlabs as $slabs) {
+ foreach(array_keys($slabs) as $slabId) {
+ $cachedump = $this->memcache->getExtendedStats('cachedump', (int)$slabId);
+ foreach($cachedump as $keys => $arrVal) {
+ if (!is_array($arrVal)) {
+ continue;
+ }
+ $list = array_merge($list, array_keys($arrVal));
+ }
+ }
+ }
+
+ return $list;
+ }
+
/**
* (@inheritdoc)
*/
}
}
+ /**
+ * (@inheritdoc)
+ */
+ public function getAllKeys()
+ {
+ return $this->memcached->getAllKeys();
+ }
+
/**
* (@inheritdoc)
*/
}
}
+ /**
+ * (@inheritdoc)
+ */
+ public function getAllKeys()
+ {
+ return null;
+ }
+
/**
* (@inheritdoc)
*/