aboutsummaryrefslogtreecommitdiffstats
path: root/library/Smarty/libs/sysplugins/smarty_cacheresource_keyvaluestore.php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2015-12-06 20:12:05 +0100
committerMario Vavti <mario@mariovavti.com>2015-12-06 20:12:05 +0100
commitc23ce16cafb826c8bb4fe7aaf2a5525b29052b23 (patch)
tree2230b03cfa6b74f3898b57bee647bc6276fd5a53 /library/Smarty/libs/sysplugins/smarty_cacheresource_keyvaluestore.php
parent78a70fed2f7cf9a53e6e4fab516b00cece12fbf0 (diff)
downloadvolse-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_keyvaluestore.php')
-rw-r--r--library/Smarty/libs/sysplugins/smarty_cacheresource_keyvaluestore.php35
1 files changed, 26 insertions, 9 deletions
diff --git a/library/Smarty/libs/sysplugins/smarty_cacheresource_keyvaluestore.php b/library/Smarty/libs/sysplugins/smarty_cacheresource_keyvaluestore.php
index a4b365a82..2fdc7e42f 100644
--- a/library/Smarty/libs/sysplugins/smarty_cacheresource_keyvaluestore.php
+++ b/library/Smarty/libs/sysplugins/smarty_cacheresource_keyvaluestore.php
@@ -36,6 +36,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
* @var array
*/
protected $contents = array();
+
/**
* cache for timestamps
*
@@ -53,10 +54,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
*/
public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
{
- $cached->filepath = $_template->source->uid
- . '#' . $this->sanitize($cached->source->resource)
- . '#' . $this->sanitize($cached->cache_id)
- . '#' . $this->sanitize($cached->compile_id);
+ $cached->filepath = $_template->source->uid . '#' . $this->sanitize($cached->source->resource) . '#' . $this->sanitize($cached->cache_id) . '#' . $this->sanitize($cached->compile_id);
$this->populateTimestamp($cached);
}
@@ -127,6 +125,28 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
}
/**
+ * Read cached template from cache
+ *
+ * @param Smarty_Internal_Template $_template template object
+ *
+ * @return string content
+ */
+ public function readCachedContent(Smarty_Internal_Template $_template)
+ {
+ $content = $_template->cached->content ? $_template->cached->content : null;
+ $timestamp = null;
+ if ($content === null) {
+ if (!$this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id, $_template->compile_id, $content, $timestamp, $_template->source->uid)) {
+ return false;
+ }
+ }
+ if (isset($content)) {
+ return $content;
+ }
+ return false;
+ }
+
+ /**
* Empty cache
* {@internal the $exp_time argument is ignored altogether }}
*
@@ -275,11 +295,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
*/
protected function getMetaTimestamp(&$content)
{
- $s = unpack("N", substr($content, 0, 4));
- $m = unpack("N", substr($content, 4, 4));
- $content = substr($content, 8);
-
- return $s[1] + ($m[1] / 100000000);
+ extract(unpack('N1s/N1m/a*content', $content));
+ return $s + ($m / 100000000);
}
/**