cvs: php4 /pear Cache.php /pear/Cache Output.php OutputCompression.php
| From: | Jon Parise | Date: | Tue, 15 May 2001 15:33:45 +0000 |
| Subject: | cvs: php4 /pear Cache.php /pear/Cache Output.php OutputCompression.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-144@lists.php.net to get a copy of this message | ||
jon Tue May 15 08:33:45 2001 EDT
Modified files:
/php4/pear Cache.php
/php4/pear/Cache Output.php OutputCompression.php
Log:
- Renaming $no_cache to $caching and inverting it's meaning
- Adding accessors for private $caching flag: getCaching() and setCaching()
Index: php4/pear/Cache.php
diff -u php4/pear/Cache.php:1.11 php4/pear/Cache.php:1.12
--- php4/pear/Cache.php:1.11 Tue Apr 24 01:27:11 2001
+++ php4/pear/Cache.php Tue May 15 08:33:44 2001
@@ -16,7 +16,7 @@
// | Sebastian Bergmann <sb@sebastian-bergmann.de> |
// +----------------------------------------------------------------------+
//
-// $Id: Cache.php,v 1.11 2001/04/24 08:27:11 uw Exp $
+// $Id: Cache.php,v 1.12 2001/05/15 15:33:44 jon Exp $
require_once "Cache/Error.php";
@@ -58,21 +58,21 @@
* bad circumstances (especially with the file container)
*
* @author Ulf Wendel <ulf.wendel@phpdoc.de>
-* @version $Id: Cache.php,v 1.11 2001/04/24 08:27:11 uw Exp $
+* @version $Id: Cache.php,v 1.12 2001/05/15 15:33:44 jon Exp $
* @package Cache
* @access public
*/
class Cache extends PEAR {
/**
- * Disables the caching.
+ * Enables / disables caching.
*
* TODO: Add explanation what this is good for.
*
* @var boolean
- * @access public
+ * @access private
*/
- var $no_cache = false;
+ var $caching = true;
/**
* Garbage collection: probability in seconds
@@ -142,6 +142,28 @@
}
/**
+ * Returns the current caching state.
+ *
+ * @return boolean The current caching state.
+ * @access public
+ */
+ function getCaching()
+ {
+ return ($this->caching);
+ }
+
+ /**
+ * Enables or disables caching.
+ *
+ * @param boolean The new caching state.
+ * @access public
+ */
+ function setCaching($state)
+ {
+ $this->caching = $state;
+ }
+
+ /**
* Returns the requested dataset it if exists and is not expired
*
* @param string dataset ID
@@ -150,7 +172,7 @@
* @access public
*/
function get($id, $group = "default") {
- if ($this->no_cache)
+ if (!$this->caching)
return "";
if ($this->isCached($id, $group) && !$this->isExpired($id, $group))
@@ -170,7 +192,7 @@
* @access public
*/
function save($id, $data, $expires = 0, $group = "default") {
- if ($this->no_cache)
+ if (!$this->caching)
return true;
return $this->extSave($id, $data, "",$expires, $group);
@@ -190,7 +212,7 @@
* @see getUserdata()
*/
function extSave($id, $cachedata, $userdata, $expires = 0, $group = "default") {
- if ($this->no_cache)
+ if (!$this->caching)
return true;
return $this->container->save($id, $cachedata, $expires, $group, $userdata);
@@ -205,7 +227,7 @@
* @access public
*/
function load($id, $group = "default") {
- if ($this->no_cache)
+ if (!$this->caching)
return "";
return $this->container->load($id, $group);
@@ -221,7 +243,7 @@
* @see extSave()
*/
function getUserdata($id, $group = "default") {
- if ($this->no_cache)
+ if (!$this->caching)
return "";
return $this->container->getUserdata($id, $group);
@@ -236,7 +258,7 @@
* @access public
*/
function delete($id, $group = "default") {
- if ($this->no_cache)
+ if (!$this->caching)
return true;
return $this->container->delete($id, $group);
@@ -249,7 +271,7 @@
* @return integer number of removed datasets
*/
function flush($group = "") {
- if ($this->no_cache)
+ if (!$this->caching)
return true;
return $this->container->flush($group);
@@ -266,7 +288,7 @@
* @access public
*/
function isCached($id, $group = "default") {
- if ($this->no_cache)
+ if (!$this->caching)
return false;
return $this->container->isCached($id, $group);
@@ -287,7 +309,7 @@
* @access public
*/
function isExpired($id, $group = "default", $max_age = 0) {
- if ($this->no_cache)
+ if (!$this->caching)
return true;
return $this->container->isExpired($id, $group, $max_age);
@@ -317,7 +339,7 @@
function garbageCollection($force = false) {
static $last_run = 0;
- if ($this->no_cache)
+ if (!$this->caching)
return;
srand((double) microtime() * 1000000);
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.15 php4/pear/Cache/Output.php:1.16
--- php4/pear/Cache/Output.php:1.15 Sat Mar 17 08:06:31 2001
+++ php4/pear/Cache/Output.php Tue May 15 08:33:45 2001
@@ -17,7 +17,7 @@
// | Vinai Kopp <kopp@netzarbeiter.de> |
// +----------------------------------------------------------------------+
//
-// $Id: Output.php,v 1.15 2001/03/17 16:06:31 chregu Exp $
+// $Id: Output.php,v 1.16 2001/05/15 15:33:45 jon Exp $
require_once 'Cache.php';
@@ -130,7 +130,7 @@
* @access public
*/
function start($id, $group = "default") {
- if ($this->no_cache)
+ if (!$this->caching)
return "";
// this is already cached return it from the cache so that the user
@@ -163,7 +163,7 @@
ob_end_clean();
// store in the cache
- if (!$this->no_cache)
+ if ($this->caching)
$this->container->save($this->output_id, $content, $expire,
$this->output_group, $userdata);
return $content;
Index: php4/pear/Cache/OutputCompression.php
diff -u php4/pear/Cache/OutputCompression.php:1.2 php4/pear/Cache/OutputCompression.php:1.3
--- php4/pear/Cache/OutputCompression.php:1.2 Mon May 14 02:01:03 2001
+++ php4/pear/Cache/OutputCompression.php Tue May 15 08:33:45 2001
@@ -23,7 +23,7 @@
*
* Based upon a case study from Christian Stocker and inspired by jpcache.
*
-* @version $Id: OutputCompression.php,v 1.2 2001/05/14 09:01:03 chregu Exp $
+* @version $Id: OutputCompression.php,v 1.3 2001/05/15 15:33:45 jon Exp $
* @author Ulf Wendel <ulf.wendel@phpdoc.de>, Christian Stocker <chregu@nomad.ch>
* @access public
* @package Cache
@@ -84,7 +84,7 @@
function get($id, $group) {
$this->content = "";
- if ($this->no_cache)
+ if (!$this->caching)
return "";
if ($this->isCached($id, $group) && !$this->isExpired($id, $group))
@@ -105,7 +105,7 @@
ob_end_clean();
// store in the cache
- if (!$this->no_cache) {
+ if ($this->caching) {
$this->extSave($this->output_id, $content, $userdata, $expire,
$this->output_group);
return $this->content;
}
@@ -124,7 +124,7 @@
*
*/
function extSave($id, $cachedata, $userdata, $expires = 0, $group = "default") {
- if ($this->no_cache)
+ if (!$this->caching)
return true;
if ($this->compression) {
@@ -155,7 +155,7 @@
if ("" == $content)
$content = &$this->content;
- if ($this->compression && !$this->no_cache) {
+ if ($this->compression && $this->caching) {
$etag = 'PEAR-Cache-' . md5(substr($content, -40));
header("ETag: $etag");