X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FCache.php;h=ea7807031fde7389479dfb2bad49c1d342094e2c;hb=743e7d3ecb4bc06999284bffd977265abc23731f;hp=cc77d9bfd0dc7e35598130af672287454ffdd25c;hpb=19209f6826fc513b5e1bc3460c212a4b80c02049;p=friendica.git diff --git a/src/Core/Cache.php b/src/Core/Cache.php index cc77d9bfd0..ea7807031f 100644 --- a/src/Core/Cache.php +++ b/src/Core/Cache.php @@ -23,13 +23,15 @@ class Cache extends \Friendica\BaseObject /** * @var Cache\ICacheDriver */ - private static $driver = null; + private static $driver = null; + public static $driver_class = null; + public static $driver_name = null; public static function init() { - $driver_name = Config::get('system', 'cache_driver', 'database'); - - self::$driver = CacheDriverFactory::create($driver_name); + self::$driver_name = Config::get('system', 'cache_driver', 'database'); + self::$driver = CacheDriverFactory::create(self::$driver_name); + self::$driver_class = get_class(self::$driver); } /** @@ -46,6 +48,29 @@ class Cache extends \Friendica\BaseObject 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 * @@ -107,12 +132,12 @@ class Cache extends \Friendica\BaseObject /** * @brief Remove outdated data from the cache * - * @param integer $max_level The maximum cache level that is to be cleared + * @param boolean $outdated just remove outdated values * * @return void */ - public static function clear() + public static function clear($outdated = true) { - return self::getDriver()->clear(); + return self::getDriver()->clear($outdated); } }