diff options
author | Mario Vavti <mario@mariovavti.com> | 2015-12-06 20:12:05 +0100 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2015-12-06 20:12:05 +0100 |
commit | c23ce16cafb826c8bb4fe7aaf2a5525b29052b23 (patch) | |
tree | 2230b03cfa6b74f3898b57bee647bc6276fd5a53 /library/Smarty/libs/sysplugins/smarty_cacheresource.php | |
parent | 78a70fed2f7cf9a53e6e4fab516b00cece12fbf0 (diff) | |
download | volse-hubzilla-c23ce16cafb826c8bb4fe7aaf2a5525b29052b23.tar.gz volse-hubzilla-c23ce16cafb826c8bb4fe7aaf2a5525b29052b23.tar.bz2 volse-hubzilla-c23ce16cafb826c8bb4fe7aaf2a5525b29052b23.zip |
update smarty library - seems to bring some performance improvement
Diffstat (limited to 'library/Smarty/libs/sysplugins/smarty_cacheresource.php')
-rw-r--r-- | library/Smarty/libs/sysplugins/smarty_cacheresource.php | 225 |
1 files changed, 6 insertions, 219 deletions
diff --git a/library/Smarty/libs/sysplugins/smarty_cacheresource.php b/library/Smarty/libs/sysplugins/smarty_cacheresource.php index 667bee44f..622ab6fbc 100644 --- a/library/Smarty/libs/sysplugins/smarty_cacheresource.php +++ b/library/Smarty/libs/sysplugins/smarty_cacheresource.php @@ -16,19 +16,12 @@ abstract class Smarty_CacheResource { /** - * cache for Smarty_CacheResource instances - * - * @var array - */ - public static $resources = array(); - - /** * resource types provided by the core * * @var array */ protected static $sysplugins = array( - 'file' => true, + 'file' => 'smarty_internal_cacheresource_file.php', ); /** @@ -204,21 +197,16 @@ abstract class Smarty_CacheResource } // try sysplugins dir if (isset(self::$sysplugins[$type])) { - if (!isset(self::$resources[$type])) { - $cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type); - self::$resources[$type] = new $cache_resource_class(); + $cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type); + if (!class_exists($cache_resource_class, false)) { + require SMARTY_SYSPLUGINS_DIR . self::$sysplugins[$type]; } - - return $smarty->_cacheresource_handlers[$type] = self::$resources[$type]; + return $smarty->_cacheresource_handlers[$type] = new $cache_resource_class(); } // try plugins dir $cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type); if ($smarty->loadPlugin($cache_resource_class)) { - if (!isset(self::$resources[$type])) { - self::$resources[$type] = new $cache_resource_class(); - } - - return $smarty->_cacheresource_handlers[$type] = self::$resources[$type]; + return $smarty->_cacheresource_handlers[$type] = new $cache_resource_class(); } // give up throw new SmartyException("Unable to load cache resource '{$type}'"); @@ -239,204 +227,3 @@ abstract class Smarty_CacheResource } } } - -/** - * Smarty Resource Data Object - * Cache Data Container for Template Files - * - * @package Smarty - * @subpackage TemplateResources - * @author Rodney Rehm - */ -class Smarty_Template_Cached -{ - /** - * Source Filepath - * - * @var string - */ - public $filepath = false; - - /** - * Source Content - * - * @var string - */ - public $content = null; - - /** - * Source Timestamp - * - * @var integer - */ - public $timestamp = false; - - /** - * Source Existence - * - * @var boolean - */ - public $exists = false; - - /** - * Cache Is Valid - * - * @var boolean - */ - public $valid = false; - - /** - * Cache was processed - * - * @var boolean - */ - public $processed = false; - - /** - * CacheResource Handler - * - * @var Smarty_CacheResource - */ - public $handler = null; - - /** - * Template Compile Id (Smarty_Internal_Template::$compile_id) - * - * @var string - */ - public $compile_id = null; - - /** - * Template Cache Id (Smarty_Internal_Template::$cache_id) - * - * @var string - */ - public $cache_id = null; - - /** - * Id for cache locking - * - * @var string - */ - public $lock_id = null; - - /** - * flag that cache is locked by this instance - * - * @var bool - */ - public $is_locked = false; - - /** - * Source Object - * - * @var Smarty_Template_Source - */ - public $source = null; - - /** - * create Cached Object container - * - * @param Smarty_Internal_Template $_template template object - */ - public function __construct(Smarty_Internal_Template $_template) - { - $this->compile_id = $_template->compile_id; - $this->cache_id = $_template->cache_id; - $this->source = $_template->source; - $_template->cached = $this; - $smarty = $_template->smarty; - - // - // load resource handler - // - $this->handler = $handler = Smarty_CacheResource::load($smarty); // Note: prone to circular references - - // - // check if cache is valid - // - if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || $_template->source->recompiled) { - $handler->populate($this, $_template); - - return; - } - while (true) { - while (true) { - $handler->populate($this, $_template); - if ($this->timestamp === false || $smarty->force_compile || $smarty->force_cache) { - $this->valid = false; - } else { - $this->valid = true; - } - if ($this->valid && $_template->caching == Smarty::CACHING_LIFETIME_CURRENT && $_template->cache_lifetime >= 0 && time() > ($this->timestamp + $_template->cache_lifetime)) { - // lifetime expired - $this->valid = false; - } - if ($this->valid || !$_template->smarty->cache_locking) { - break; - } - if (!$this->handler->locked($_template->smarty, $this)) { - $this->handler->acquireLock($_template->smarty, $this); - break 2; - } - } - if ($this->valid) { - if (!$_template->smarty->cache_locking || $this->handler->locked($_template->smarty, $this) === null) { - // load cache file for the following checks - if ($smarty->debugging) { - Smarty_Internal_Debug::start_cache($_template); - } - if ($handler->process($_template, $this) === false) { - $this->valid = false; - } else { - $this->processed = true; - } - if ($smarty->debugging) { - Smarty_Internal_Debug::end_cache($_template); - } - } else { - continue; - } - } else { - return; - } - if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_SAVED && $_template->properties['cache_lifetime'] >= 0 && (time() > ($_template->cached->timestamp + $_template->properties['cache_lifetime']))) { - $this->valid = false; - } - if (!$this->valid && $_template->smarty->cache_locking) { - $this->handler->acquireLock($_template->smarty, $this); - - return; - } else { - return; - } - } - } - - /** - * Write this cache object to handler - * - * @param Smarty_Internal_Template $_template template object - * @param string $content content to cache - * - * @return boolean success - */ - public function write(Smarty_Internal_Template $_template, $content) - { - if (!$_template->source->recompiled) { - if ($this->handler->writeCachedContent($_template, $content)) { - $this->content = null; - $this->timestamp = time(); - $this->exists = true; - $this->valid = true; - if ($_template->smarty->cache_locking) { - $this->handler->releaseLock($_template->smarty, $this); - } - - return true; - } - } - - return false; - } -} |