]> granicus.if.org Git - php/commitdiff
- Renaming $no_cache to $caching and inverting it's meaning
authorJon Parise <jon@php.net>
Tue, 15 May 2001 15:33:44 +0000 (15:33 +0000)
committerJon Parise <jon@php.net>
Tue, 15 May 2001 15:33:44 +0000 (15:33 +0000)
- Adding accessors for private $caching flag: getCaching() and setCaching()

pear/Cache.php

index 3bf5be72069ae45027c2d27f000ebed0639354ee..7338bd89398539701dc4b2b470cba8c376c52146 100644 (file)
@@ -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
@@ -141,6 +141,28 @@ class Cache extends PEAR {
         $this->garbageCollection();
     }
 
+    /**
+     * 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
     *
@@ -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);