[PHP-CVS] cvs: php4 /pear Cache.php

2001-03-28 Thread Ulf Wendel

uw  Wed Mar 28 10:32:20 2001 EDT

  Modified files:  
/php4/pear  Cache.php 
  Log:
  Added a simple usage example
  
  
Index: php4/pear/Cache.php
diff -u php4/pear/Cache.php:1.8 php4/pear/Cache.php:1.9
--- php4/pear/Cache.php:1.8 Sat Mar 17 08:06:31 2001
+++ php4/pear/Cache.php Wed Mar 28 10:32:20 2001
@@ -16,21 +16,49 @@
 // |  Sebastian Bergmann [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Cache.php,v 1.8 2001/03/17 16:06:31 chregu Exp $
+// $Id: Cache.php,v 1.9 2001/03/28 18:32:20 uw Exp $
 
 require_once "Cache/Error.php";
 
 /**
 * Cache is a base class for cache implementations.
 *
-* TODO: Simple usage example goes here.
+* The pear cache module is a generic data cache which can be used to 
+* cache script runs. The idea behind the cache is quite simple. If you have
+* the same input parameters for whatever tasks/algorithm you use you'll
+* usually get the same output. So why not caching templates, functions calls,
+* graphic generation etc. Caching certain actions e.g. XSLT tranformations
+* saves you lots of time. 
 *
+* The design of the cache reminds of PHPLibs session implementation. A 
+* (PHPLib: session) controller uses storage container (PHPLib: ct_*.inc) to save 
+* certain data (PHPLib: session data). In contrast to the session stuff it's up to 
+* you to generate an ID for the data to cache. If you're using the output cache
+* you might use the script name as a seed for cache::generateID(), if your using the
+* function cache you'd use an array with all function parameters.
+*
+* Usage example of the generic data cache:
+*
+* require_once("Cache.php");
+*
+* $cache = new Cache("file", array("cache_dir" = "cache/") );
+* $id = $cache-generateID("testentry");
+*
+* if ($data = $cache-get($id)) {
+*print "Cache hit.brData: $data";
+*
+* } else {
+*   $data = "data of any kind";
+*   $cache-save($id, $data);
+*   print "Cache miss.br";
+* }
+*
 * WARNING: No File/DB-Table-Row locking is implemented yet,
 *  it's possible, that you get corrupted data-entries under
 *  bad circumstances  (especially with the file container)
 *
 * @author   Ulf Wendel [EMAIL PROTECTED]
-* @version  $Id: Cache.php,v 1.8 2001/03/17 16:06:31 chregu Exp $
+* @version  $Id: Cache.php,v 1.9 2001/03/28 18:32:20 uw Exp $
 * @package  Cache
 * @access   public
 */



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /pear Cache.php /pear/Cache Output.php

2001-03-17 Thread Christian Stocker

chregu  Sat Mar 17 08:06:31 2001 EDT

  Modified files:  
/php4/pear  Cache.php 
/php4/pear/CacheOutput.php 
  Log:
  GarbageCollection was moved into a PEAR-Deconstructor
  
  

Index: php4/pear/Cache.php
diff -u php4/pear/Cache.php:1.7 php4/pear/Cache.php:1.8
--- php4/pear/Cache.php:1.7 Thu Mar  8 12:41:39 2001
+++ php4/pear/Cache.php Sat Mar 17 08:06:31 2001
@@ -16,7 +16,7 @@
 // |  Sebastian Bergmann [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Cache.php,v 1.7 2001/03/08 20:41:39 uw Exp $
+// $Id: Cache.php,v 1.8 2001/03/17 16:06:31 chregu Exp $
 
 require_once "Cache/Error.php";
 
@@ -25,12 +25,16 @@
 *
 * TODO: Simple usage example goes here.
 *
+* WARNING: No File/DB-Table-Row locking is implemented yet,
+*  it's possible, that you get corrupted data-entries under
+*  bad circumstances  (especially with the file container)
+*
 * @author   Ulf Wendel [EMAIL PROTECTED]
-* @version  $Id: Cache.php,v 1.7 2001/03/08 20:41:39 uw Exp $
+* @version  $Id: Cache.php,v 1.8 2001/03/17 16:06:31 chregu Exp $
 * @package  Cache
-* @access   public 
+* @access   public
 */
-class Cache {
+class Cache extends PEAR {
 
 /**
 * Disables the caching.
@@ -45,8 +49,8 @@
 /**
 * Garbage collection: probability in seconds
 *
-* If set to a value above 0 a garbage collection will 
-* flush all cache entries older than the specified number 
+* If set to a value above 0 a garbage collection will
+* flush all cache entries older than the specified number
 * of seconds.
 *
 * @var  integer
@@ -68,35 +72,40 @@
 
 /**
 * Storage container object.
-* 
+*
 * @var  object Cache_Container
-*/
+*/
 var $container;
 
 //
 // public methods
 //
 
-/**
+/**
 *
 * @paramstring  Name of storage container class
 * @paramarray   Array with storage class dependend config options
 */
 function Cache($storage_driver, $storage_options = "")
 {
+$this-PEAR();
 $storage_driver = strtolower($storage_driver);
 $storage_class = 'Cache_Container_' . $storage_driver;
 $storage_classfile = 'Cache/Container/' . $storage_driver . '.php';
 
 include_once $storage_classfile;
 $this-container = new $storage_class($storage_options);
+}
+
+//deconstructor
+function _Cache()
+{
 $this-garbageCollection();
-
 }
 
 /**
 * Returns the requested dataset it if exists and is not expired
-*  
+*
 * @paramstring  dataset ID
 * @paramstring  cache group
 * @return   mixed   cached data or NULL on failure
@@ -105,16 +114,16 @@
 function get($id, $group = "default") {
 if ($this-no_cache)
 return "";
-
+
 if ($this-isCached($id, $group)  !$this-isExpired($id, $group))
 return $this-load($id, $group);
-
-return NULL;
+
+return NULL;
 } // end func get
 
 /**
 * Stores the given data in the cache.
-* 
+*
 * @paramstring  dataset ID used as cache identifier
 * @parammixed   data to cache
 * @paraminteger lifetime of the cached data in seconds - 0 for endless
@@ -125,13 +134,13 @@
 function save($id, $data, $expires = 0, $group = "default") {
 if ($this-no_cache)
 return true;
-
+
 return $this-container-save($id, $data, $expires, $group, "");
 } // end func save
 
 /**
 * Stores a dataset without additional userdefined data.
-* 
+*
 * @paramstring  dataset ID
 * @parammixed   data to store
 * @paramstring  additional userdefined data
@@ -151,16 +160,16 @@
 
 /**
 * Loads the given ID from the cache.
-* 
+*
 * @paramstring  dataset ID
 * @paramstring  cache group
-* @return   mixed   cached data or NULL on failure 
+* @return   mixed   cached data or NULL on failure
 * @access   public
 */
 function load($id, $group = "default") {
 if ($this-no_cache)
 return "";
-
+
 return $this-container-load($id, $group);
 } // end func load
 
@@ -176,13 +185,13 @@
 function getUserdata($id, $group = "default") {
 if ($this-no_cache)
 return "";
-
+
 return $this-container-getUserdata($id, $group);
 } // end func getUserdata
 
 /**
 * Removes the specified dataset from the cache.
-* 
+*
 * @paramstring  dataset ID
 * @paramstring  cache group
 * @return   boolean
@@ -191,28 +200,28 @@
 function delete($id, $group = "default") {
 if ($this-no_cache)
 return true;
-
+
 return $this-container-delete($id, $group);
 } // end func delete
 
 /**
 

[PHP-CVS] cvs: php4 /pear Cache.php /pear/Cache Container.php Error.php /pear/Cache/Container db.php file.php phplib.php

2001-03-08 Thread Ulf Wendel

uw  Thu Mar  8 12:39:17 2001 EDT

  Added files: 
/php4/pear/CacheError.php 

  Modified files:  
/php4/pear  Cache.php 
/php4/pear/CacheContainer.php 
/php4/pear/Cache/Container  db.php file.php phplib.php 
  Log:
  Added a basic Cache_Error class.
  
  
  

Index: php4/pear/Cache.php
diff -u php4/pear/Cache.php:1.5 php4/pear/Cache.php:1.6
--- php4/pear/Cache.php:1.5 Tue Mar  6 07:27:30 2001
+++ php4/pear/Cache.php Thu Mar  8 12:39:15 2001
@@ -16,15 +16,17 @@
 // |  Sebastian Bergmann [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Cache.php,v 1.5 2001/03/06 15:27:30 sbergmann Exp $
+// $Id: Cache.php,v 1.6 2001/03/08 20:39:15 uw Exp $
 
+require_once "Cache/Error.php";
+
 /**
 * Cache is a base class for cache implementations.
 *
 * TODO: Simple usage example goes here.
 *
 * @author   Ulf Wendel [EMAIL PROTECTED]
-* @version  $Id: Cache.php,v 1.5 2001/03/06 15:27:30 sbergmann Exp $
+* @version  $Id: Cache.php,v 1.6 2001/03/08 20:39:15 uw Exp $
 * @package  Cache
 * @access   public 
 */
@@ -136,7 +138,7 @@
 * @parammixed   userdefined expire date
 * @paramstring  cache group
 * @return   boolean
-* @throws   CacheError
+* @throws   Cache_Error
 * @access   public
 * @see  getUserdata()
 */
Index: php4/pear/Cache/Container.php
diff -u php4/pear/Cache/Container.php:1.7 php4/pear/Cache/Container.php:1.8
--- php4/pear/Cache/Container.php:1.7   Thu Mar  8 03:57:15 2001
+++ php4/pear/Cache/Container.php   Thu Mar  8 12:39:15 2001
@@ -17,8 +17,10 @@
 // |  Christian Stocker [EMAIL PROTECTED] |
 // +--+
 //
-// $Id: Container.php,v 1.7 2001/03/08 11:57:15 chregu Exp $
+// $Id: Container.php,v 1.8 2001/03/08 20:39:15 uw Exp $
 
+require_once "Cache/Error.php";
+
 /**
 * Common base class of all cache storage container.
 * 
@@ -37,7 +39,7 @@
 * not recommended!
 * 
 * @author   Ulf Wendel [EMAIL PROTECTED]
-* @version  $Id: Container.php,v 1.7 2001/03/08 11:57:15 chregu Exp $
+* @version  $Id: Container.php,v 1.8 2001/03/08 20:39:15 uw Exp $
 * @package  Cache
 * @access   public
 * @abstract
@@ -208,7 +210,7 @@
 * @paramstring  dataset ID
 * @paramstring  cache group
 * @return   array   format: [expire date, cached data, user data]
-* @throws   CacheError
+* @throws   Cache_Error
 * @abstract
 */
 function fetch($id, $group) {
@@ -224,7 +226,7 @@
 * @paramstring  cache group
 * @paramstring  additional userdefined data
 * @return   boolean
-* @throws   CacheError
+* @throws   Cache_Error
 * @access   public
 * @abstract
 */
Index: php4/pear/Cache/Container/db.php
diff -u php4/pear/Cache/Container/db.php:1.8 php4/pear/Cache/Container/db.php:1.9
--- php4/pear/Cache/Container/db.php:1.8Thu Mar  8 03:57:16 2001
+++ php4/pear/Cache/Container/db.phpThu Mar  8 12:39:16 2001
@@ -17,7 +17,7 @@
 // |  Chuck Hagenbuch [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: db.php,v 1.8 2001/03/08 11:57:16 chregu Exp $
+// $Id: db.php,v 1.9 2001/03/08 20:39:16 uw Exp $
 
 require_once 'DB.php';
 require_once 'Cache/Container.php';
@@ -52,7 +52,7 @@
 * )
 *
 * @author   Sebastian Bergmann [EMAIL PROTECTED]
-* @version  $Id: db.php,v 1.8 2001/03/08 11:57:16 chregu Exp $
+* @version  $Id: db.php,v 1.9 2001/03/08 20:39:16 uw Exp $
 * @package  Cache
 */
 class Cache_Container_db extends Cache_Container {
@@ -81,17 +81,17 @@
 function Cache_Container_db($options)
 {
 if (!is_array($options) || !isset($options['dsn'])) {
-return new CacheError('No dsn specified!', __FILE__, __LINE__);
+return new Cache_Error('No dsn specified!', __FILE__, __LINE__);
 }
 
 $this-setOptions($options, array('dsn', 'cache_table'));
 
 if (!$this-dsn)
-return new CacheError('No dsn specified!', __FILE__, __LINE__);
+return new Cache_Error('No dsn specified!', __FILE__, __LINE__);
 
 $this-db = DB::connect($this-dsn, true);
 if (DB::isError($this-db)) {
-return new CacheError('DB::connect failed: ' . 
DB::errorMessage($this-db), __FILE__, __LINE__);
+return new Cache_Error('DB::connect failed: ' . 
+DB::errorMessage($this-db), __FILE__, __LINE__);
 } else {
 $this-db-setFetchMode(DB_FETCHMODE_ASSOC);
 }
@@ -108,7 +108,7 @@
 $res = $this-db-query($query);
 
 if (DB::isError($res))
-return new CacheError('DB::query failed: ' . DB::errorMessage($res), 
__FILE__, __LINE__);
+return new Cache_Error('DB::query failed: ' . DB::errorMessage($res), 
+__FILE__, __LINE__);
 
 $row = 

[PHP-CVS] cvs: php4 /pear Cache.php /pear/Cache Container.php

2001-03-08 Thread Ulf Wendel

uw  Thu Mar  8 12:41:40 2001 EDT

  Modified files:  
/php4/pear  Cache.php 
/php4/pear/CacheContainer.php 
  Log:
  Formatting and minor inline doc changes.
  
  
  
Index: php4/pear/Cache.php
diff -u php4/pear/Cache.php:1.6 php4/pear/Cache.php:1.7
--- php4/pear/Cache.php:1.6 Thu Mar  8 12:39:15 2001
+++ php4/pear/Cache.php Thu Mar  8 12:41:39 2001
@@ -16,7 +16,7 @@
 // |  Sebastian Bergmann [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Cache.php,v 1.6 2001/03/08 20:39:15 uw Exp $
+// $Id: Cache.php,v 1.7 2001/03/08 20:41:39 uw Exp $
 
 require_once "Cache/Error.php";
 
@@ -26,7 +26,7 @@
 * TODO: Simple usage example goes here.
 *
 * @author   Ulf Wendel [EMAIL PROTECTED]
-* @version  $Id: Cache.php,v 1.6 2001/03/08 20:39:15 uw Exp $
+* @version  $Id: Cache.php,v 1.7 2001/03/08 20:41:39 uw Exp $
 * @package  Cache
 * @access   public 
 */
@@ -281,5 +281,6 @@
 $last_run = time();
 }
 } // end func garbageCollection
+
 } // end class cache 
 ?
Index: php4/pear/Cache/Container.php
diff -u php4/pear/Cache/Container.php:1.8 php4/pear/Cache/Container.php:1.9
--- php4/pear/Cache/Container.php:1.8   Thu Mar  8 12:39:15 2001
+++ php4/pear/Cache/Container.php   Thu Mar  8 12:41:39 2001
@@ -17,7 +17,7 @@
 // |  Christian Stocker [EMAIL PROTECTED] |
 // +--+
 //
-// $Id: Container.php,v 1.8 2001/03/08 20:39:15 uw Exp $
+// $Id: Container.php,v 1.9 2001/03/08 20:41:39 uw Exp $
 
 require_once "Cache/Error.php";
 
@@ -39,7 +39,7 @@
 * not recommended!
 * 
 * @author   Ulf Wendel [EMAIL PROTECTED]
-* @version  $Id: Container.php,v 1.8 2001/03/08 20:39:15 uw Exp $
+* @version  $Id: Container.php,v 1.9 2001/03/08 20:41:39 uw Exp $
 * @package  Cache
 * @access   public
 * @abstract
@@ -364,6 +364,7 @@
 return serialize($data);
 } // end func encode
 
+
 /**
 * Decodes the data from the storage container.
 * 
@@ -376,19 +377,19 @@
 return unserialize($data);
 } // end func decode
 
+
 /**
 * Translates human readable/relative times in unixtime
 *
-* @var  mixed   can be in the following formats:
+* @param  mixed   can be in the following formats:
 *   human readable  : mmddhhmm[ss]] eg: 20010308095100
 *   relative in seconds (1) : +xx  eg: +10
 *   relative in seconds (2) : x   946681200   eg: 10
 *   absolute unixtime   : x  2147483648   eg: 2147483648
 *   see comments in code for details
+* @return integer unix timestamp
 */
-
 function getExpiresAbsolute($expires)
-
 {
 if (!$expires)
 return 0;
@@ -416,6 +417,8 @@
 $second = substr($expires, 12, 2);
 return mktime($hour, $minute, $second, $month, $day, $year);
 }
-}
-}
+
+} // end func getExpireAbsolute
+
+} // end class Container
 ?



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-CVS] cvs: php4 /pear Cache.php /pear/Cache Container.phpError.php /pear/Cache/Container db.php file.php phplib.php

2001-03-08 Thread Christian Stocker

 No Message Collected 

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /pear Cache.php /pear/Cache Container.php Graphics.php Output.php /pear/Cache/Container db.php file.php phplib.php

2001-03-06 Thread Sebastian Bergmann

sbergmann   Tue Mar  6 07:27:30 2001 EDT

  Modified files:  
/php4/pear  Cache.php 
/php4/pear/CacheContainer.php Graphics.php Output.php 
/php4/pear/Cache/Container  db.php file.php phplib.php 
  Log:
  Whitespace only.
  

Index: php4/pear/Cache.php
diff -u php4/pear/Cache.php:1.4 php4/pear/Cache.php:1.5
--- php4/pear/Cache.php:1.4 Sun Mar  4 06:26:58 2001
+++ php4/pear/Cache.php Tue Mar  6 07:27:30 2001
@@ -16,7 +16,7 @@
 // |  Sebastian Bergmann [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Cache.php,v 1.4 2001/03/04 14:26:58 mj Exp $
+// $Id: Cache.php,v 1.5 2001/03/06 15:27:30 sbergmann Exp $
 
 /**
 * Cache is a base class for cache implementations.
@@ -24,7 +24,7 @@
 * TODO: Simple usage example goes here.
 *
 * @author   Ulf Wendel [EMAIL PROTECTED]
-* @version  $Id: Cache.php,v 1.4 2001/03/04 14:26:58 mj Exp $
+* @version  $Id: Cache.php,v 1.5 2001/03/06 15:27:30 sbergmann Exp $
 * @package  Cache
 * @access   public 
 */
@@ -63,7 +63,7 @@
 * @access   public
 */
 var $gc_probability = 1;
-
+
 /**
 * Storage container object.
 * 
@@ -91,7 +91,7 @@
 $this-garbageCollection();
 
 }
-
+
 /**
 * Returns the requested dataset it if exists and is not expired
 *  
@@ -110,7 +110,6 @@
 return NULL;
 } // end func get
 
-
 /**
 * Stores the given data in the cache.
 * 
@@ -127,8 +126,7 @@
 
 return $this-container-save($id, $data, $expires, $group, "");
 } // end func save
-
-
+
 /**
 * Stores a dataset without additional userdefined data.
 * 
@@ -149,7 +147,6 @@
 return $this-container-save($id, $cachedata, $expires, $group, $userdata);
 } // end func extSave
 
-
 /**
 * Loads the given ID from the cache.
 * 
@@ -164,8 +161,7 @@
 
 return $this-container-load($id, $group);
 } // end func load
-
-
+
 /**
 * Returns the userdata field of a cached data set.
 *
@@ -181,8 +177,7 @@
 
 return $this-container-getUserdata($id, $group);
 } // end func getUserdata
-
-
+
 /**
 * Removes the specified dataset from the cache.
 * 
@@ -197,8 +192,7 @@
 
 return $this-container-delete($id, $group);
 } // end func delete
-
-
+
 /**
 * Flushes the cache - removes all data from it
 * 
@@ -211,8 +205,7 @@
 
 return $this-container-flush($group);
 } // end func flush
-
-
+
 /**
 * Checks if a dataset exists.
 * 
@@ -229,8 +222,7 @@
 
 return $this-container-isCached($id, $group);
 } // end func isCached
-
-
+
 /**
 * Checks if a dataset is expired
 * 
@@ -251,7 +243,7 @@
 
 return $this-container-isExpired($id, $group, $max_age);
 } // end func isExpired
-
+
 /**
 * Generates a "unique" ID for the given value
 * 
@@ -286,9 +278,6 @@
 $this-container-garbageCollection();
 $last_run = time();
 }
-
 } // end func garbageCollection
-
-
 } // end class cache 
 ?
Index: php4/pear/Cache/Container.php
diff -u php4/pear/Cache/Container.php:1.5 php4/pear/Cache/Container.php:1.6
--- php4/pear/Cache/Container.php:1.5   Tue Mar  6 03:32:10 2001
+++ php4/pear/Cache/Container.php   Tue Mar  6 07:27:30 2001
@@ -1,5 +1,4 @@
 ?php
-
 // +--+
 // | PHP version 4.0  |
 // +--+
@@ -17,7 +16,7 @@
 // |  Sebastian Bergmann [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Container.php,v 1.5 2001/03/06 11:32:10 chregu Exp $
+// $Id: Container.php,v 1.6 2001/03/06 15:27:30 sbergmann Exp $
 
 /**
 * Common base class of all cache storage container.
@@ -37,7 +36,7 @@
 * not recommended!
 * 
 * @author   Ulf Wendel [EMAIL PROTECTED]
-* @version  $Id: Container.php,v 1.5 2001/03/06 11:32:10 chregu Exp $
+* @version  $Id: Container.php,v 1.6 2001/03/06 15:27:30 sbergmann Exp $
 * @package  Cache
 * @access   public
 * @abstract
@@ -52,63 +51,56 @@
 * @var  boolean
 */
 var $preload = true;
-
+
 /**
 * ID of a preloaded dataset
 *
 * @var  string
 */
 var $id = "";
-
-
+
 /**
 * Cache group of a preloaded dataset
 *
 * @var  string
 */
 var $group = "";
-
-
+
 /**
 * Expiration timestamp of a preloaded dataset.
 * 
 * @var  integer 0 means never, endless
 */
 var $expires = 0;
-
-
+
 /**
 * Value of a preloaded dataset.
 * 
 * @var  string
 */
 

[PHP-CVS] cvs: php4 /pear Cache.php

2001-03-04 Thread Martin Jansen

mj  Sun Mar  4 06:26:59 2001 EDT

  Modified files:  
/php4/pear  Cache.php 
  Log:
  fixed typo
  
  
Index: php4/pear/Cache.php
diff -u php4/pear/Cache.php:1.3 php4/pear/Cache.php:1.4
--- php4/pear/Cache.php:1.3 Sat Mar  3 11:21:49 2001
+++ php4/pear/Cache.php Sun Mar  4 06:26:58 2001
@@ -16,7 +16,7 @@
 // |  Sebastian Bergmann [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Cache.php,v 1.3 2001/03/03 19:21:49 uw Exp $
+// $Id: Cache.php,v 1.4 2001/03/04 14:26:58 mj Exp $
 
 /**
 * Cache is a base class for cache implementations.
@@ -24,7 +24,7 @@
 * TODO: Simple usage example goes here.
 *
 * @author   Ulf Wendel [EMAIL PROTECTED]
-* @version  $Id: Cache.php,v 1.3 2001/03/03 19:21:49 uw Exp $
+* @version  $Id: Cache.php,v 1.4 2001/03/04 14:26:58 mj Exp $
 * @package  Cache
 * @access   public 
 */
@@ -86,7 +86,7 @@
 $storage_class = 'Cache_Container_' . $storage_driver;
 $storage_classfile = 'Cache/Container/' . $storage_driver . '.php';
 
-include_once $storage_classfile
+include_once $storage_classfile;
 $this-container = new $storage_class($storage_options);
 $this-garbageCollection();
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /pear Cache.php

2001-03-03 Thread Ulf Wendel

uw  Sat Mar  3 11:21:50 2001 EDT

  Modified files:  
/php4/pear  Cache.php 
  Log:
  The main file with new features.
- added support for cache dataset groups
- added extSave() - see my next PEAR list posting
- added getUserdata() 
  
  
  
Index: php4/pear/Cache.php
diff -u php4/pear/Cache.php:1.2 php4/pear/Cache.php:1.3
--- php4/pear/Cache.php:1.2 Fri Mar  2 02:29:34 2001
+++ php4/pear/Cache.php Sat Mar  3 11:21:49 2001
@@ -16,7 +16,7 @@
 // |  Sebastian Bergmann [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Cache.php,v 1.2 2001/03/02 10:29:34 sbergmann Exp $
+// $Id: Cache.php,v 1.3 2001/03/03 19:21:49 uw Exp $
 
 /**
 * Cache is a base class for cache implementations.
@@ -24,7 +24,7 @@
 * TODO: Simple usage example goes here.
 *
 * @author   Ulf Wendel [EMAIL PROTECTED]
-* @version  $Id: Cache.php,v 1.2 2001/03/02 10:29:34 sbergmann Exp $
+* @version  $Id: Cache.php,v 1.3 2001/03/03 19:21:49 uw Exp $
 * @package  Cache
 * @access   public 
 */
@@ -79,115 +79,163 @@
 *
 * @paramstring  Name of storage container class
 * @paramarray   Array with storage class dependend config options
-* @see  setOptions()
 */
 function Cache($storage_driver, $storage_options = "")
 {
 $storage_driver = strtolower($storage_driver);
 $storage_class = 'Cache_Container_' . $storage_driver;
 $storage_classfile = 'Cache/Container/' . $storage_driver . '.php';
-   
-if (@include_once $storage_classfile) {
-$this-container = new $storage_class($storage_options);
-$this-garbageCollection();
-} else {
-return null;
-}
+
+include_once $storage_classfile
+$this-container = new $storage_class($storage_options);
+$this-garbageCollection();
+
 }
 
 /**
 * Returns the requested dataset it if exists and is not expired
 *  
 * @paramstring  dataset ID
+* @paramstring  cache group
 * @return   mixed   cached data or NULL on failure
 * @access   public
 */
-function get($id) {
+function get($id, $group = "default") {
 if ($this-no_cache)
 return "";
 
-if ($this-isCached($id)  !$this-isExpired($id))
-return $this-load($id);
+if ($this-isCached($id, $group)  !$this-isExpired($id, $group))
+return $this-load($id, $group);
 
 return NULL;
 } // end func get
 
+
 /**
 * Stores the given data in the cache.
 * 
 * @paramstring  dataset ID used as cache identifier
 * @parammixed   data to cache
 * @paraminteger lifetime of the cached data in seconds - 0 for endless
+* @paramstring  cache group
 * @return   boolean
 * @access   public
 */
-function save($id, $data, $expires = 0) {
+function save($id, $data, $expires = 0, $group = "default") {
 if ($this-no_cache)
 return true;
 
-return $this-container-save($id, $data, $expires);
+return $this-container-save($id, $data, $expires, $group, "");
 } // end func save
 
+
+/**
+* Stores a dataset without additional userdefined data.
+* 
+* @paramstring  dataset ID
+* @parammixed   data to store
+* @paramstring  additional userdefined data
+* @parammixed   userdefined expire date
+* @paramstring  cache group
+* @return   boolean
+* @throws   CacheError
+* @access   public
+* @see  getUserdata()
+*/
+function extSave($id, $cachedata, $userdata, $expires = 0, $group = "default") {
+if ($this-no_cache)
+return true;
+
+return $this-container-save($id, $cachedata, $expires, $group, $userdata);
+} // end func extSave
+
+
 /**
 * Loads the given ID from the cache.
 * 
 * @paramstring  dataset ID
+* @paramstring  cache group
 * @return   mixed   cached data or NULL on failure 
 * @access   public
 */
-function load($id) {
+function load($id, $group = "default") {
 if ($this-no_cache)
 return "";
 
-return $this-container-load($id);
+return $this-container-load($id, $group);
 } // end func load
 
+
+/**
+* Returns the userdata field of a cached data set.
+*
+* @paramstring  dataset ID
+* @paramstring  cache group
+* @return   string  userdata
+* @access   public
+* @see  extSave()
+*/
+function getUserdata($id, $group = "default") {
+if ($this-no_cache)
+return "";
+
+return $this-container-getUserdata($id, $group);
+} // end func getUserdata
+
+
 /**
 * Removes the specified dataset from the cache.
 * 
 * 

[PHP-CVS] cvs: php4 /pear Cache.php

2001-03-02 Thread Sebastian Bergmann

sbergmann   Fri Mar  2 02:29:35 2001 EDT

  Modified files:  
/php4/pear  Cache.php 
  Log:
  Whitespace only.
  
Index: php4/pear/Cache.php
diff -u php4/pear/Cache.php:1.1 php4/pear/Cache.php:1.2
--- php4/pear/Cache.php:1.1 Thu Mar  1 08:32:28 2001
+++ php4/pear/Cache.php Fri Mar  2 02:29:34 2001
@@ -16,7 +16,7 @@
 // |  Sebastian Bergmann [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Cache.php,v 1.1 2001/03/01 16:32:28 chagenbu Exp $
+// $Id: Cache.php,v 1.2 2001/03/02 10:29:34 sbergmann Exp $
 
 /**
 * Cache is a base class for cache implementations.
@@ -24,7 +24,7 @@
 * TODO: Simple usage example goes here.
 *
 * @author   Ulf Wendel [EMAIL PROTECTED]
-* @version  $Id: Cache.php,v 1.1 2001/03/01 16:32:28 chagenbu Exp $
+* @version  $Id: Cache.php,v 1.2 2001/03/02 10:29:34 sbergmann Exp $
 * @package  Cache
 * @access   public 
 */
@@ -85,7 +85,7 @@
 {
 $storage_driver = strtolower($storage_driver);
 $storage_class = 'Cache_Container_' . $storage_driver;
-   $storage_classfile = 'Cache/Container/' . $storage_driver . '.php';
+$storage_classfile = 'Cache/Container/' . $storage_driver . '.php';

 if (@include_once $storage_classfile) {
 $this-container = new $storage_class($storage_options);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /pear Cache.php /pear/Cache Cache.php Container.php /pear/Cache/Container cache_container.php cache_container_file.php cache_container_phplib.php cache_container_shm.php file.php phplib.php shm.php

2001-03-01 Thread Chuck Hagenbuch

chagenbuThu Mar  1 08:32:30 2001 EDT

  Added files: 
/php4/pear  Cache.php 
/php4/pear/CacheContainer.php 
/php4/pear/Cache/Container  file.php phplib.php shm.php 

  Removed files:   
/php4/pear/CacheCache.php 
/php4/pear/Cache/Container  cache_container.php 
cache_container_file.php 
cache_container_phplib.php 
cache_container_shm.php 
  Log:
  use standard naming/capitalization, and do a bit of error checking when
  instantiating the storage classfile.
  
  


Index: php4/pear/Cache.php
+++ php4/pear/Cache.php
?php
// +--+
// | PHP version 4.0  |
// +--+
// | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group |
// +--+
// | This source file is subject to version 2.0 of the PHP license,   |
// | that is bundled with this package in the file LICENSE, and is|
// | available at through the world-wide-web at   |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to  |
// | [EMAIL PROTECTED] so we can mail you a copy immediately.   |
// +--+
// | Authors: Ulf Wendel [EMAIL PROTECTED]   |
// |  Sebastian Bergmann [EMAIL PROTECTED]   |
// +--+
//
// $Id: Cache.php,v 1.1 2001/03/01 16:32:28 chagenbu Exp $

/**
* Cache is a base class for cache implementations.
*
* TODO: Simple usage example goes here.
*
* @author   Ulf Wendel [EMAIL PROTECTED]
* @version  $Id: Cache.php,v 1.1 2001/03/01 16:32:28 chagenbu Exp $
* @package  Cache
* @access   public 
*/
class Cache {

/**
* Disables the caching.
*
* TODO: Add explanation what this is good for.
*
* @var  boolean
* @access   public
*/
var $no_cache = false;

/**
* Garbage collection: probability in seconds
*
* If set to a value above 0 a garbage collection will 
* flush all cache entries older than the specified number 
* of seconds.
*
* @var  integer
* @see  $gc_probability
* @access   public
*/
var $gc_time  = 1;

/**
* Garbage collection: probability in percent
*
* TODO: Add an explanation.
*
* @var  integer 0 = never
* @see  $gc_time
* @access   public
*/
var $gc_probability = 1;

/**
* Storage container object.
* 
* @var  object Cache_Container
*/
var $container;

//
// public methods
//

/**
*
* @paramstring  Name of storage container class
* @paramarray   Array with storage class dependend config options
* @see  setOptions()
*/
function Cache($storage_driver, $storage_options = "")
{
$storage_driver = strtolower($storage_driver);
$storage_class = 'Cache_Container_' . $storage_driver;
$storage_classfile = 'Cache/Container/' . $storage_driver . '.php';

if (@include_once $storage_classfile) {
$this-container = new $storage_class($storage_options);
$this-garbageCollection();
} else {
return null;
}
}

/**
* Returns the requested dataset it if exists and is not expired
*  
* @paramstring  dataset ID
* @return   mixed   cached data or NULL on failure
* @access   public
*/
function get($id) {
if ($this-no_cache)
return "";

if ($this-isCached($id)  !$this-isExpired($id))
return $this-load($id);

return NULL;
} // end func get

/**
* Stores the given data in the cache.
* 
* @paramstring  dataset ID used as cache identifier
* @parammixed   data to cache
* @paraminteger lifetime of the cached data in seconds - 0 for endless
* @return   boolean
* @access   public
*/
function save($id, $data, $expires = 0) {
if ($this-no_cache)
return true;

return $this-container-save($id, $data, $expires);
} // end func save

/**
* Loads the given ID from the cache.
* 
* @paramstring  dataset ID
* @return   mixed   cached data or NULL on failure 
* @access   public
*/
function load($id) {
if ($this-no_cache)
return "";

return