ApcUniversalClassLoader.php 994 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\ClassLoader;
  11. require_once __DIR__.'/UniversalClassLoader.php';
  12. /**
  13. * Class loader utilizing APC to remember where files are.
  14. *
  15. * @author Kris Wallsmith <kris.wallsmith@symfony.com>
  16. *
  17. * @api
  18. */
  19. class ApcUniversalClassLoader extends UniversalClassLoader
  20. {
  21. private $prefix;
  22. /**
  23. * Constructor.
  24. *
  25. * @param string $prefix A prefix to create a namespace in APC
  26. *
  27. * @api
  28. */
  29. public function __construct($prefix)
  30. {
  31. $this->prefix = $prefix;
  32. }
  33. public function findFile($class)
  34. {
  35. if (false === $file = apc_fetch($this->prefix.$class)) {
  36. apc_store($this->prefix.$class, $file = parent::findFile($class));
  37. }
  38. return $file;
  39. }
  40. }