You are here

class ApcClassLoader in X Autoload 7.5

Same name and namespace in other branches
  1. 7.4 lib/ClassLoader/ApcClassLoader.php \Drupal\xautoload\ClassLoader\ApcClassLoader

Hierarchy

Expanded class hierarchy of ApcClassLoader

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

File

src/ClassLoader/ApcClassLoader.php, line 8

Namespace

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

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

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

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

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