Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ClassLoader] added an apc class loader
- Loading branch information
1 parent
757e4ea
commit 441a154
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\ClassLoader; | ||
|
||
require_once __DIR__.'/UniversalClassLoader.php'; | ||
|
||
/** | ||
* Class loader utilizing APC to remember where files are. | ||
* | ||
* @author Kris Wallsmith <kris.wallsmith@symfony.com> | ||
*/ | ||
class ApcUniversalClassLoader extends UniversalClassLoader | ||
{ | ||
private $prefix; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param string $prefix A prefix to create a namespace in APC | ||
*/ | ||
public function __construct($prefix) | ||
{ | ||
$this->prefix = $prefix; | ||
} | ||
|
||
protected function findFile($class) | ||
{ | ||
if (false === $file = apc_fetch($this->prefix.$class)) { | ||
apc_store($this->prefix.$class, $file = parent::findFile($class)); | ||
} | ||
|
||
return $file; | ||
} | ||
} |