/**
* @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);
}
/**
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
*
/**
* @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);
}
}