You are here

class ApcuClassLoader in X Autoload 7.5

Hierarchy

Expanded class hierarchy of ApcuClassLoader

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

File

src/ClassLoader/ApcuClassLoader.php, line 8

Namespace

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

  /**
   * @return bool
   */
  protected function checkRequirements() {
    return extension_loaded('apcu') && function_exists('apcu_store');
  }

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

    // Look if the cache has anything for this class.
    if ($file = \apcu_fetch($this->prefix . $class)) {
      if (is_file($file)) {
        require $file;
        return;
      }
      \apcu_delete($this->prefix . $class);
    }

    // Resolve cache miss.
    $api = new LoadClassGetFileInjectedApi($class);
    if ($this->finder
      ->apiFindFile($api, $class)) {
      \apcu_store($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
ApcuClassLoader::checkRequirements protected function Overrides AbstractCachedClassLoader::checkRequirements
ApcuClassLoader::loadClass function Callback for class loading. This will include ("require") the file found. Overrides AbstractClassLoaderDecorator::loadClass