Use class name as cache key
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
|
||||
class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache
|
||||
{
|
||||
private $directory;
|
||||
private $baseDir;
|
||||
private $fileMode;
|
||||
|
||||
public function __construct($directory, $fileMode = null)
|
||||
public function __construct($baseDir, $fileMode = null)
|
||||
{
|
||||
$this->directory = $directory;
|
||||
$this->baseDir = $baseDir;
|
||||
$this->fileMode = $fileMode;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache
|
||||
|
||||
protected function getCacheFilename($name)
|
||||
{
|
||||
return sprintf('%s/%s.php', $this->directory, md5($name));
|
||||
return sprintf('%s/%s.php', $this->baseDir, $name);
|
||||
}
|
||||
|
||||
private function buildDirectoryForFilename($fileName)
|
||||
@@ -76,7 +76,7 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache
|
||||
$mode = isset($this->fileMode) ? $this->fileMode : (0666 & ~umask());
|
||||
@chmod($fileName, $mode);
|
||||
|
||||
return $fileName;
|
||||
return;
|
||||
}
|
||||
|
||||
$this->log(
|
||||
|
||||
@@ -11,8 +11,8 @@ class Mustache_Cache_NoopCache extends Mustache_Cache_AbstractCache
|
||||
{
|
||||
$this->log(
|
||||
Mustache_Logger::WARNING,
|
||||
'Template cache disabled, evaluating class at runtime',
|
||||
array()
|
||||
'Template cache disabled, evaluating "{className}" class at runtime',
|
||||
array('className' => $className)
|
||||
);
|
||||
eval("?>".$compiled);
|
||||
}
|
||||
|
||||
@@ -506,7 +506,7 @@ class Mustache_Engine
|
||||
public function getCache()
|
||||
{
|
||||
if (!isset($this->cache)) {
|
||||
$this->cache = new Mustache_Cache_NoopCache();
|
||||
$this->setCache(new Mustache_Cache_NoopCache());
|
||||
}
|
||||
|
||||
return $this->cache;
|
||||
@@ -613,9 +613,9 @@ class Mustache_Engine
|
||||
|
||||
if (!isset($this->templates[$className])) {
|
||||
if (!class_exists($className, false)) {
|
||||
if (!$this->getCache()->load($source)) {
|
||||
if (!$this->getCache()->load($className)) {
|
||||
$compiled = $this->compile($source);
|
||||
$this->getCache()->cache($source, $compiled);
|
||||
$this->getCache()->cache($className, $compiled);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user