/**
* @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);
}
/**
/**
* @brief Returns all the cache keys sorted alphabetically
*
- * @return array|null Null if the driver doesn't support this feature
+ * @param string $prefix Prefix of the keys (optional)
+ *
+ * @return array Empty if the driver doesn't support this feature
*/
- public static function getAllKeys()
+ public static function getAllKeys($prefix = null)
{
$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);
+ $return = self::getDriver()->getAllKeys($prefix);
- self::getApp()->save_timestamp($time, 'cache');
+ self::getApp()->saveTimestamp($time, 'cache');
return $return;
}
$return = self::getDriver()->get($key);
- self::getApp()->save_timestamp($time, 'cache');
+ self::getApp()->saveTimestamp($time, 'cache');
return $return;
}
$return = self::getDriver()->set($key, $value, $duration);
- self::getApp()->save_timestamp($time, 'cache_write');
+ self::getApp()->saveTimestamp($time, 'cache_write');
return $return;
}
$return = self::getDriver()->delete($key);
- self::getApp()->save_timestamp($time, 'cache_write');
+ self::getApp()->saveTimestamp($time, 'cache_write');
return $return;
}