You are here

class XCacheClassLoader in X Autoload 7.4

Same name and namespace in other branches
  1. 7.5 src/ClassLoader/XCacheClassLoader.php \Drupal\xautoload\ClassLoader\XCacheClassLoader

Hierarchy

Expanded class hierarchy of XCacheClassLoader

1 file declares its use of XCacheClassLoader
xautoload.module in ./xautoload.module

File

lib/ClassLoader/XCacheClassLoader.php, line 8

Namespace

Drupal\xautoload\ClassLoader
View source
class XCacheClassLoader extends AbstractCachedClassLoader implements CacheManagerObserverInterface {

  /**
   * @throws \Exception
   *   Throws an exception, if requirements are not satisfied.
   */
  protected function checkRequirements() {
    return extension_loaded('Xcache') && function_exists('xcache_isset');
  }

  /**
   * {@inheritdoc}
   */
  function loadClass($class) {

    // Look if the cache has anything for this class.
    if (xcache_isset($this->prefix . $class) && ($file = xcache_get($this->prefix . $class))) {
      if (is_file($file)) {
        require $file;
        return;
      }
      xcache_unset($this->prefix . $class);
    }

    // Resolve cache miss.
    $api = new LoadClassGetFileInjectedApi($class);
    if ($this->finder
      ->apiFindFile($api, $class)) {
      xcache_set($this->prefix . $class, $api
        ->getFile());
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractCachedClassLoader::$prefix protected property
AbstractCachedClassLoader::create static function This method has side effects, so it is not the constructor.
AbstractCachedClassLoader::setCachePrefix function Set the APC prefix after a flush cache. Overrides CacheManagerObserverInterface::setCachePrefix
AbstractClassLoader::register function Registers this instance as an autoloader. Overrides ClassLoaderInterface::register
AbstractClassLoader::unregister function Unregister from the spl autoload stack. Overrides ClassLoaderInterface::unregister
AbstractClassLoaderDecorator::$finder protected property
AbstractClassLoaderDecorator::setFinder function Replace the finder with another one.
AbstractClassLoaderDecorator::__construct protected function
XCacheClassLoader::checkRequirements protected function Overrides AbstractCachedClassLoader::checkRequirements
XCacheClassLoader::loadClass function Callback for class loading. This will include ("require") the file found. Overrides AbstractClassLoaderDecorator::loadClass