load($name); } public static function set($name, $data) { return self::getCache()->save($data, $name); } protected static function getCache() { if (null === self::$cache) { self::$cache = Qs_Cache::factory('Core', 'File', ['automatic_serialization' => true]); $cacheDir = constant('BASE_PATH') . '/tmp/result-cache/'; if (!is_dir($cacheDir)) { if (false === mkdir($cacheDir, 0777, true) || !is_writable($cacheDir)) { throw new \Exception('Cache directory does not exists or is not writable'); } } self::$cache->getBackend()->setOption('cache_dir', $cacheDir); } return self::$cache; } }