This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "quickfw".
The branch, master has been updated
via a24ffd90c66679d87c93eeedbf0b6b77c522e1f2 (commit)
via eae7215e0e312c3d026ad3fd30b4d8d162240a18 (commit)
from cecb9148cad4fbf19d4f1ae7ac4764852fabf495 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a24ffd90c66679d87c93eeedbf0b6b77c522e1f2
Author: Ivan Borzenkov <iva...@li...>
Date: Sun Aug 21 01:29:28 2011 +0400
Фикс calling
diff --git a/QFW/Templater/PlainView.php b/QFW/Templater/PlainView.php
index a96ee90..c2650d2 100644
--- a/QFW/Templater/PlainView.php
+++ b/QFW/Templater/PlainView.php
@@ -41,7 +41,7 @@ class PlainView_Delegate
*
* @return bool можно вызывать
*/
- public function callable()
+ public function calling()
{
return $this->m !== false;
}
@@ -102,7 +102,7 @@ class Templater_PlainView extends Templater
$data = ob_get_clean();
$caller = array_pop($this->callers);
$caller instanceof PlainView_Delegate;
- echo $caller->callable() ? $caller->run($data) : $data;
+ echo $caller->calling() ? $caller->run($data) : $data;
}
public function extend($tpl)
commit eae7215e0e312c3d026ad3fd30b4d8d162240a18
Author: Ivan Borzenkov <iva...@li...>
Date: Sun Aug 21 01:28:13 2011 +0400
Обновление dklabCache
diff --git a/QFW/QuickFW/Cacher/Namespace.php b/QFW/QuickFW/Cacher/Namespace.php
index a9322d1..a774f38 100644
--- a/QFW/QuickFW/Cacher/Namespace.php
+++ b/QFW/QuickFW/Cacher/Namespace.php
@@ -19,19 +19,28 @@ class Dklab_Cache_Backend_NamespaceWrapper implements Zend_Cache_Backend_Interfa
return $this->_backend->setDirectives($directives);
}
- public function load($id, $doNotTest = false)
- {
- $id = is_array($id) ? array_map(array($this, '_mangleId'), $id) : $this->_mangleId($id);
- $data = $this->_backend->load($id, $doNotTest);
-
- if (!is_array($id) || !is_array($data))
- return $data;
- $d = array();
- $l = strlen($this->_namespace) + 1;
- foreach($data as $k=>$v)
- $d[substr($k, $l)] = $v;
- return $d;
+ public function load($id, $doNotTestCacheValidity = false)
+ {
+ return $this->_backend->load($this->_mangleId($id), $doNotTestCacheValidity);
}
+
+ public function multiLoad($ids, $doNotTestCacheValidity = false)
+ {
+ if (!is_array($ids)) {
+ Zend_Cache::throwException('multiLoad() expects parameter 1 to be array, ' . gettype($ids) . ' given');
+ }
+ if (method_exists($this->_backend, 'multiLoad')) {
+ return $this->_backend->multiLoad($this->_mangleIds($ids), $doNotTestCacheValidity);
+ }
+ // No multiLoad() method avalilable, so we have to emulate it to keep
+ // the interface consistent.
+ $result = array();
+ foreach ($ids as $i => $id) {
+ $result[$id] = $this->load($id, $doNotTestCacheValidity);
+ }
+ return $result;
+ }
+
public function test($id)
{
return $this->_backend->test($this->_mangleId($id));
diff --git a/QFW/QuickFW/Cacher/Slot.php b/QFW/QuickFW/Cacher/Slot.php
index c8beba0..faa83e2 100644
--- a/QFW/QuickFW/Cacher/Slot.php
+++ b/QFW/QuickFW/Cacher/Slot.php
@@ -110,6 +110,9 @@ abstract class Dklab_Cache_Frontend_Slot
*/
public function addTag(Dklab_Cache_Frontend_Tag $tag)
{
+ if ($tag->getBackend() !== $this->_getBackend()) {
+ Zend_Cache::throwException("Backends for tag " . get_class($tag) . " and slot " . get_class($this) . " must be same");
+ }
$this->_tags[] = $tag;
}
diff --git a/QFW/QuickFW/Cacher/TagEmu.php b/QFW/QuickFW/Cacher/TagEmu.php
index 3aaa189..1542754 100644
--- a/QFW/QuickFW/Cacher/TagEmu.php
+++ b/QFW/QuickFW/Cacher/TagEmu.php
@@ -1,17 +1,39 @@
<?php
/**
- * Dklab_Cache - сохраняем начальные копирайты, но код переписан :)
+ * Dklab_Cache_Backend_TagEmuWrapper: tag wrapper for any Zend_Cache backend.
+ *
+ * Implements tags. Tags are emulated via keys: unfortunately this
+ * increases the data read cost (the more tags are assigned to a key,
+ * the more read cost becomes).
+ *
+ * $Id$
*/
class Dklab_Cache_Backend_TagEmuWrapper implements Zend_Cache_Backend_Interface
{
- const VERSION = "01";
+ const VERSION = "1.50";
+
private $_backend = null;
- public function __construct(Zend_Cache_Backend_Interface $backend) {$this->_backend = $backend;}
- public function setDirectives($directives) {return $this->_backend->setDirectives($directives);}
- public function load($id, $doNotTest = false) {return $this->_loadOrTest($id, $doNotTest, false);}
+ public function __construct(Zend_Cache_Backend_Interface $backend)
+ {
+ $this->_backend = $backend;
+ }
+
+
+ public function setDirectives($directives)
+ {
+ return $this->_backend->setDirectives($directives);
+ }
+
+
+ public function load($id, $doNotTestCacheValidity = false)
+ {
+ return $this->_loadOrTest($id, $doNotTestCacheValidity, false);
+ }
+
+
public function save($data, $id, $tags = array(), $specificLifetime = false)
{
// Save/update tags as usual infinite keys with value of tag version.
@@ -33,10 +55,11 @@ class Dklab_Cache_Backend_TagEmuWrapper implements Zend_Cache_Backend_Interface
$serialized = serialize($combined);
return $this->_backend->save($serialized, $id, array(), $specificLifetime);
}
+
- public function clean($mode = CACHE_CLR_ALL, $tags = array())
+ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
{
- if ($mode == CACHE_CLR_TAG) {
+ if ($mode == Zend_Cache::CLEANING_MODE_MATCHING_TAG) {
if (is_array($tags)) {
foreach ($tags as $tag) {
$this->_backend->remove($this->_mangleTag($tag));
@@ -46,53 +69,100 @@ class Dklab_Cache_Backend_TagEmuWrapper implements Zend_Cache_Backend_Interface
return $this->_backend->clean($mode, $tags);
}
}
+
+
+ public function test($id)
+ {
+ return $this->_loadOrTest($id, false, true);
+ }
+
+
+ public function remove($id)
+ {
+ return $this->_backend->remove($id);
+ }
- public function test($id) {return $this->_loadOrTest($id, false, true);}
- public function remove($id) {return $this->_backend->remove($id);}
/**
* Mangles the name to deny intersection of tag keys & data keys.
* Mangled tag names are NOT saved in memcache $combined[0] value,
* mangling is always performed on-demand (to same some space).
- *
+ *
* @param string $tag Tag name to mangle.
* @return string Mangled tag name.
*/
- private function _mangleTag($tag) {return __CLASS__ . "_" . self::VERSION . "_" . $tag;}
+ private function _mangleTag($tag)
+ {
+ return __CLASS__ . "_" . self::VERSION . "_" . $tag;
+ }
+
+
+ /**
+ * The same as _mangleTag(), but mangles a list of tags.
+ *
+ * @see self::_mangleTag
+ * @param array $tags Tags to mangle.
+ * @return array List of mangled tags.
+ */
+ private function _mangleTags($tags)
+ {
+ foreach ($tags as $i => $tag) {
+ $tags[$i] = $this->_mangleTag($tag);
+ }
+ return $tags;
+ }
+
/**
* Common method called from load() and test().
- *
+ *
* @param string $id
* @param bool $doNotTestCacheValidity
* @param bool $returnTrueIfValid If true, returns not the value contained
* in the slot, but "true".
* @return mixed
*/
- private function _loadOrTest($id, $doNotTest = false, $returnTrueIfValid = false)
+ private function _loadOrTest($id, $doNotTestCacheValidity = false, $returnTrueIfValid = false)
{
// Data is saved in form of: array(tagsWithVersionArray, anyData).
- $serialized = $this->_backend->load($id, $doNotTest);
+ $serialized = $this->_backend->load($id, $doNotTestCacheValidity);
if ($serialized === false) {
return false;
}
$combined = unserialize($serialized);
if (!is_array($combined)) {
return false;
- }
+ }
// Test if all tags has the same version as when the slot was created
// (i.e. still not removed and then recreated).
- if (is_array($combined[0])) {
- foreach ($combined[0] as $tag => $savedTagVersion) {
- $actualTagVersion = $this->_backend->load($this->_mangleTag($tag));
- if ($actualTagVersion !== $savedTagVersion) {
- return false;
+ if (is_array($combined[0]) && $combined[0]) {
+ if (method_exists($this->_backend, 'multiLoad')) {
+ // If we have multiLoad(), optimize queries into one.
+ $allMangledTagValues = $this->_backend->multiLoad($this->_mangleTags(array_keys($combined[0])));
+ foreach ($combined[0] as $tag => $savedTagVersion) {
+ $actualTagVersion = @$allMangledTagValues[$this->_mangleTag($tag)];
+ if ($actualTagVersion !== $savedTagVersion) {
+ return false;
+ }
+ }
+ } else {
+ // Check all tags versions AND STOP IF WE FOUND AN INCONSISTENT ONE.
+ // Note that this optimization works fine only if $this->_backend is
+ // references to Dklab_Cache_Backend, but NOT via Dklab_Cache_Backend
+ // wrappers, because such wrappers emulate multiLoad() via multiple
+ // load() calls.
+ foreach ($combined[0] as $tag => $savedTagVersion) {
+ $actualTagVersion = $this->_backend->load($this->_mangleTag($tag));
+ if ($actualTagVersion !== $savedTagVersion) {
+ return false;
+ }
}
}
}
return $returnTrueIfValid? true : $combined[1];
}
+
/**
* Generates a new unique identifier for tag version.
*
@@ -105,5 +175,3 @@ class Dklab_Cache_Backend_TagEmuWrapper implements Zend_Cache_Backend_Interface
return md5(microtime() . getmypid() . uniqid('') . $counter);
}
}
-
-?>
\ No newline at end of file
-----------------------------------------------------------------------
Summary of changes:
QFW/QuickFW/Cacher/Namespace.php | 33 +++++++----
QFW/QuickFW/Cacher/Slot.php | 3 +
QFW/QuickFW/Cacher/TagEmu.php | 112 ++++++++++++++++++++++++++++++--------
QFW/Templater/PlainView.php | 4 +-
4 files changed, 116 insertions(+), 36 deletions(-)
hooks/post-receive
--
quickfw
|