summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Parise <jon@php.net>2001-05-15 15:39:45 +0000
committerJon Parise <jon@php.net>2001-05-15 15:39:45 +0000
commit98b62b9c93a8d10e20ef16ac0db46e760b4787b0 (patch)
treebb60420d6defe8f939f106835dde459b716e96de
parent52006e0d05da720125b271d6058ae39f02246305 (diff)
downloadphp-git-98b62b9c93a8d10e20ef16ac0db46e760b4787b0.tar.gz
(Merge from head branch)
- Renaming $no_cache to $caching and inverting it's meaning - Adding accessors for private $caching flag: getCaching() and setCaching()
-rw-r--r--pear/Cache.php48
1 files changed, 35 insertions, 13 deletions
diff --git a/pear/Cache.php b/pear/Cache.php
index 3bf5be7206..7338bd8939 100644
--- a/pear/Cache.php
+++ b/pear/Cache.php
@@ -65,14 +65,14 @@ require_once "Cache/Error.php";
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 @@ class Cache extends PEAR {
}
/**
+ * 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 @@ class Cache extends PEAR {
* @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 @@ class Cache extends PEAR {
* @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 @@ class Cache extends PEAR {
* @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 @@ class Cache extends PEAR {
* @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 @@ class Cache extends PEAR {
* @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 @@ class Cache extends PEAR {
* @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 @@ class Cache extends PEAR {
* @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 @@ class Cache extends PEAR {
* @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 @@ class Cache extends PEAR {
* @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 @@ class Cache extends PEAR {
function garbageCollection($force = false) {
static $last_run = 0;
- if ($this->no_cache)
+ if (!$this->caching)
return;
srand((double) microtime() * 1000000);