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 c6714502a469a3834a755a661c08f289e0989919 (commit)
from f86cff47e740c38da7c9cc242959f4e4c902299b (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 c6714502a469a3834a755a661c08f289e0989919
Author: Ivan1986 <iva...@li...>
Date: Tue Mar 30 17:10:35 2010 +0400
Переписан кешер Berkeley DB через наследование
diff --git a/QFW/Cacher/Bdb.php b/QFW/Cacher/Bdb.php
index ad44598..a798617 100644
--- a/QFW/Cacher/Bdb.php
+++ b/QFW/Cacher/Bdb.php
@@ -26,29 +26,18 @@ class Cacher_Bdb implements Zend_Cache_Backend_Interface
public function save($data, $id, $tags = array(), $specificLifetime = 3600)
{
if (!$this->file) $this->conn();
- return dba_replace($id,serialize(array(time()+$specificLifetime,$data)),$this->file);
+ return dba_replace($id,serialize($data),$this->file);
}
public function load($id, $doNotTest = false)
{
if (!$this->file) $this->conn();
- if (is_array($id))
- {
- $x = array();
- foreach($id as $v)
- $x[$v] = $this->load($v);
- return $x;
- }
- $data=dba_fetch($id,$this->file);
- if (!$data)
- return false;
- $data=unserialize($data);
- if ($data[0]<time())
- {
- dba_delete($id,$this->file);
- return false;
- }
- return $data[1];
+ if (!is_array($id))
+ return unserialize(dba_fetch($id,$this->file));
+ $x = array();
+ foreach($id as $v)
+ $x[$v] = $this->load($v);
+ return $x;
}
public function test($id)
diff --git a/QFW/Cacher/BdbSt.php b/QFW/Cacher/BdbSt.php
deleted file mode 100644
index 2dc9932..0000000
--- a/QFW/Cacher/BdbSt.php
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-
-class Cacher_BdbSt implements Zend_Cache_Backend_Interface
-{
- protected $file = NULL;
- protected $opt = array();
-
- public function __construct()
- {
- }
-
- public function setDirectives($directives)
- {
- $this->opt = array(
- 'file' => isset($directives['file']) ? $directives['file'] : 'cache',
- 'dba' => isset($directives['dba']) ? $directives['dba'] : 'db4',
- 'type' => isset($directives['type']) ? $directives['type'] : 'cd',
- );
- }
-
- private function conn()
- {
- $this->file=dba_open(TMPPATH.'/'.$this->opt['file'].'.'.$this->opt['dba'], $this->opt['type'], $this->opt['dba']);
- }
-
- public function save($data, $id, $tags = array(), $specificLifetime = 3600)
- {
- if (!$this->file) $this->conn();
- return dba_replace($id,serialize($data),$this->file);
- }
-
- public function load($id, $doNotTest = false)
- {
- if (!$this->file) $this->conn();
- if (!is_array($id))
- return unserialize(dba_fetch($id,$this->file));
- $x = array();
- foreach($id as $v)
- $x[$v] = $this->load($v);
- return $x;
- }
-
- public function test($id)
- {
- return ($this->load($id)!==false);
- }
-
- public function remove($id)
- {
- if (!$this->file) $this->conn();
- return dba_delete($id,$this->file);
- }
-
- public function clean($mode = CACHE_CLR_ALL, $tags = array())
- {
- if (!$this->file) $this->conn();
- $key=dba_firstkey($this->file);
- if (!$key)
- return;
- do {
- if ($mode == CACHE_CLR_ALL)
- dba_delete($key,$this->file);
- elseif($mode == CACHE_CLR_OLD)
- {
- $data=dba_fetch($key,$this->file);
- $data=unserialize($data);
- if ($data[0]<time())
- dba_delete($key,$this->file);
- }
- } while($key=dba_nextkey($this->file));
- dba_optimize($this->file);
- dba_sync($this->file);
- }
-
-}
-?>
\ No newline at end of file
diff --git a/QFW/Cacher/BdbTime.php b/QFW/Cacher/BdbTime.php
new file mode 100644
index 0000000..818d1f1
--- /dev/null
+++ b/QFW/Cacher/BdbTime.php
@@ -0,0 +1,36 @@
+<?php
+
+require_once dirname(__FILE__).'/Bdb.php';
+
+/**
+ * Хранение в Berkeley DB ограниченное время
+ */
+class Cacher_BdbTime extends Cacher_Bdb implements Zend_Cache_Backend_Interface
+{
+
+ public function save($data, $id, $tags = array(), $specificLifetime = 3600)
+ {
+ $data = serialize(array(time()+$specificLifetime,$data));
+ return parent::save($data, $id, $tags, $specificLifetime);
+ }
+
+ public function load($id, $doNotTest = false)
+ {
+ if (!$this->file) $this->conn();
+ if (is_array($id))
+ return parent::load($id, $doNotTest);
+ $data = parent::load($id, $doNotTest);
+ if (!$data)
+ return false;
+ $data=unserialize($data);
+ if ($data[0]<time())
+ {
+ dba_delete($id,$this->file);
+ return false;
+ }
+ return $data[1];
+ }
+
+}
+
+?>
-----------------------------------------------------------------------
Summary of changes:
QFW/Cacher/Bdb.php | 25 ++++-----------
QFW/Cacher/BdbSt.php | 76 ------------------------------------------------
QFW/Cacher/BdbTime.php | 36 ++++++++++++++++++++++
3 files changed, 43 insertions(+), 94 deletions(-)
delete mode 100644 QFW/Cacher/BdbSt.php
create mode 100644 QFW/Cacher/BdbTime.php
hooks/post-receive
--
quickfw
|